首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未定义对`boost::this_thread::interruption_point()‘的引用

未定义对`boost::this_thread::interruption_point()‘的引用
EN

Stack Overflow用户
提问于 2012-08-12 02:48:19
回答 2查看 6.5K关注 0票数 4

我正在尝试使用boost和rtmidi编译一个项目。然而,我一直收到以下编译错误。我使用的是linux、netbeans 7.2、boost 1.50.0和rtmidi 2.1.0。

代码语言:javascript
复制
g++ -D__LINUX_ALSA__ -lasound -lpthread 
-I/usr/local/boost_1_50_0 
-L/usr/local/boost_1_50_0/lib -L/usr/local/lib -L/usr/lib 
-lboost_system    
-o dist/Debug/GNU-Linux-x86/realtimebeatgenerationthesis build/Debug/GNU-Linux-x86/State.o build/Debug/GNU-Linux-x86/RawNote.o build/Debug/GNU-Linux-x86/MarkovEngineConsumer.o build/Debug/GNU-Linux-x86/Calibrator.o build/Debug/GNU-Linux-x86/main.o build/Debug/GNU-Linux-x86/MidiHandlerProducer.o build/Debug/GNU-Linux-x86/LetterPattern.o build/Debug/GNU-Linux-x86/Letter.o build/Debug/GNU-Linux-x86/Meter.o build/Debug/GNU-Linux-x86/VOMC.o build/Debug/GNU-Linux-x86/Metronome.o  

我得到的错误消息有两个部分:

代码语言:javascript
复制
undefined reference to `boost::this_thread::interruption_point()'

代码语言:javascript
复制
undefined reference to `RtMidiOut::RtMidiOut(RtMidi::Api, std::string)'
collect2: error: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/realtimebeatgenerationthesis] Error 1
make[2]: Leaving directory `dir/NetBeansProjects/RealTimeBeat'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `dir/NetBeansProjects/RealTimeBeat'
make: *** [.build-impl] Error 2

编辑-1:嘿@matomatician1975,即使添加了我得到的那一个:

代码语言:javascript
复制
undefined reference to `boost::this_thread::interruption_point()'
build/Debug/GNU-Linux-x86/MarkovEngineConsumer.o: In function     `__static_initialization_and_destruction_0':
/usr/local/boost_1_50_0/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
/usr/local/boost_1_50_0/boost/system/error_code.hpp:215: undefined reference to  `boost::system::generic_category()'
/usr/local/boost_1_50_0/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'

最后,我通过链接器添加->添加库、boost_thread、boost_system和rtmidi,最终使其正常工作。在命令行中会出现类似以下内容的结果:

代码语言:javascript
复制
g++ -Wall -D__LINUX_ALSA__ -I/usr/local -L/usr/local/lib/ -L/alsa/ -lasound -lpthread -o          build/Debug/GNU-Linux-x86/Calibrator.o ..../main.o ...../MidiHandlerProducer.o ...../LetterPattern.o ..../Letter.o ..../Meter.o ..../VOMC.o ..../Metronome.o -L/usr/local/lib -lboost_thread -lboost_system -lrtmidi 
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-08-12 03:01:52

您似乎没有链接到boost线程库。尝试在构建路径中添加-lboost_thread

票数 11
EN

Stack Overflow用户

发布于 2014-12-12 07:53:33

我也有同样的问题,尽管我确信我链接的东西是正确的。如果你进一步阅读你的错误输出,你可能会发现架构不匹配:

代码语言:javascript
复制
ld: warning: ignoring file /.../boost/lib/libboost_system.dylib, file was built for x86_64 which is not the architecture being linked (i386)
ld: warning: ignoring file /.../boost/lib/libboost_filesystem.dylib, file was built for x86_64 which is not the architecture being linked (i386):
ld: warning: ignoring file /.../boost/lib/libboost_thread.dylib, file was built for x86_64 which is not the architecture being linked (i386):
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11916733

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档