0

我最近从 Visual Studio 2010 Express 切换到使用 NetBeans,我已经对布局和简单性印象深刻,尽管它确实需要一点点推动才能正确编译。但是,我还有另一个问题。当我测试 boost 是否也能正常工作时,我将文件 boost/signals.hpp 包含在 main.cpp 中,然后转到项目选项中的其他库目录并添加我的 boost 安装的 lib 目录,与我会在视觉工作室做。毕竟,我还是得到了一堆未定义的引用。

我正在使用带有 msys 的 mingw 编译器,如果这有什么不同的话,我有 boost 1.47 版。我可以确认,在使用 Visual Studio 时,同样的 boost 安装工作正常。

这是构建日志。

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory m`/c/Users/me/Documents/NetBeansProjects/Syncopate5/Syncopate5'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/syncopate5.exe
make[2]: Entering directory `/c/Users/me/Documents/NetBeansProjects/Syncopate5/Syncopate5'
mkdir -p dist/Debug/MinGW-Windows
g++.exe     -o dist/Debug/MinGW-Windows/syncopate5 build/Debug/MinGW-Windows/main.o -L/C/Program\ Files\ \(x86\)/boost/boost_1_47/lib 
build/Debug/MinGW-Windows/main.o: In function `ZN5boost7signal0IvNS_10last_valueIvEEiSt4lessIiENS_8functionIFvvEEEED2Ev':
C:\Users\me\Documents\NetBeansProjects\Syncopate5\Syncopate5/../../../../../../Program Files (x86)/boost/boost_1_47/boost/signals/signal_template.hpp:139: undefined reference to `boost::signals::trackable::~trackable()'
C:\Users\me\Documents\NetBeansProjects\Syncopate5\Syncopate5/../../../../../../Program Files (x86)/boost/boost_1_47/boost/signals/signal_template.hpp:139: undefined reference to `boost::signals::detail::signal_base::~signal_base()'
make[2]: Leaving directory `/c/Users/me/Documents/NetBeansProjects/Syncopate5/Syncopate5'
C:\Users\me\Documents\NetBeansProjects\Syncopate5\Syncopate5/../../../../../../Program Files (x86)/boost/boost_1_47/boost/signals/signal_template.hpp:139: undefined reference to `boost::signals::detail::signal_base::~signal_base()'
make[1]: Leaving directory `/c/Users/me/Documents/NetBeansProjects/Syncopate5/Syncopate5'
build/Debug/MinGW-Windows/main.o: In function `ZN5boost7signal0IvNS_10last_valueIvEEiSt4lessIiENS_8functionIFvvEEEEC2ERKS2_RKS4_':
C:\Users\me\Documents\NetBeansProjects\Syncopate5\Syncopate5/../../../../../../Program Files (x86)/boost/boost_1_47/boost/signals/signal_template.hpp:197: undefined reference to `boost::signals::detail::signal_base::signal_base(boost::function2<bool, boost::signals::detail::stored_group, boost::signals::detail::stored_group> const&, boost::any const&)'
C:\Users\me\Documents\NetBeansProjects\Syncopate5\Syncopate5/../../../../../../Program Files (x86)/boost/boost_1_47/boost/signals/signal_template.hpp:197: undefined reference to `boost::signals::detail::signal_base::~signal_base()'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [dist/Debug/MinGW-Windows/syncopate5.exe] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

编辑:

尝试通过项目属性中的添加库对话框手动添加所需的 lib 文件后,我收到此错误。

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/c/Users/me/Documents/NetBeansProjects/Syncopate5/Syncopate5'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/syncopate5.exe
make[2]: Entering directory `/c/Users/me/Documents/NetBeansProjects/Syncopate5/Syncopate5'
make[2]: *** No rule to make target `../../../../../../Program Files \(x86\)/boost/boost_1_47/lib/libboost_signals-vc100-mt-1_47.lib', needed by `dist/Debug/MinGW-Windows/syncopate5.exe'.  Stop.
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
make[2]: Leaving directory `/c/Users/me/Documents/NetBeansProjects/Syncopate5/Syncopate5'
make[1]: Leaving directory `/c/Users/me/Documents/NetBeansProjects/Syncopate5/Syncopate5'

BUILD FAILED (exit value 2, total time: 9s)
4

2 回答 2

1

这取决于您如何构建项目。

如果您从现有的 makefile 构建项目,则您的库路径和库应该存在于构建环境中。

如果您通过将源、包含和库逐个合并来手动构建项目,则需要显式添加所需的库。

具体来说,查看您更新的构建日志,您似乎没有链接所需的库,而是以某种方式将其添加为目标。

Right click on your project, go to Properties, under the Build tab look toward Linker, Here is where you should specify your link path and your dynamic/static libraries.

于 2013-02-08T12:12:38.597 回答
0

After hours of googling and reading, i have discovered a little more about boost and finally found and understand my problem. When i originally obtained my install of boost, it was from BoostPro which has all the header only objects, as well as precompiled binaries for vc++ ONLY. After obtaining the most recent version of boost, and boost.build to create gcc versions of the libraries and linking against them, it worked without a hitch. Thanks Tyler Jandreau an Joachim Pileborg for answering my inherently flawed question :.

于 2013-02-09T03:05:56.307 回答