2012-08-11 70 views
1

我想編譯一個項目使用boost和rtmidi。但是,我不斷收到以下編譯錯誤。 我使用的是linux,netbeans 7.2,boost 1.50.0和rtmidi 2.1.0。該錯誤消息我得到的未定義的引用`boost :: this_thread :: interruption_point()'

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 

兩個部分:

undefined reference to `boost::this_thread::interruption_point()' 

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: 嘿@ mathematician1975,甚至通過添加一個我得到:

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使其工作。導致在命令行中類似於以下內容:

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 

回答

7

您似乎不鏈接到boost線程庫。嘗試在您的構建路徑中添加-lboost_thread

+0

我剛纔編輯的描述(EDIT-1) – 2012-08-11 19:09:47

+0

你需要'-lboost_thread'和'-lboost_system'。 – 2012-08-11 19:12:40

+0

-lboost_system已經在編譯行(4)中。奇怪的是,即使我包含以下鏈接,我仍然會遇到同樣的錯誤。 – 2012-08-11 19:33:35

0

我有同樣的問題,儘管肯定我正確地連接了東西。如果你的錯誤輸出繼續讀下去,你會發現建築的不匹配:

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): 
相關問題