我在linux下UBUNTU下工作在eclipse 10.10,使用Synaptic pkg管理器安裝boost-dev軟件包1.40。我是Linux新手,這個提升pkg。我嘗試創建一個新的項目,並寫上:不能編譯,如果包括提升/線程在Linux Ubuntu 10.10
#include <boost/thread.hpp>
int main(int argc, char* argv[]){
}
我不包括任何東西,或任何地方寫這樣並行線程東西。 試圖建立的時候,它說:
/usr/include/boost/config/requires_threads.hpp:47: error: #error "Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
In file included from /usr/include/boost/thread/thread.hpp:12,
from /usr/include/boost/thread.hpp:13,
from ../main.cpp:8:
/usr/include/boost/thread/detail/platform.hpp:67: error: #error "Sorry, no boost threads are available for this platform."
In file included from /usr/include/boost/thread.hpp:13,
from ../main.cpp:8:
/usr/include/boost/thread/thread.hpp:19: error: #error "Boost threads unavailable on this platform"
等等,很多相關的多個錯誤的提振。 我試圖將-pthread
,-pthreads
,-lpthread
添加到我認爲可以的地方,但沒有解決問題。 我忘了提及,我試圖在eclipse中構建項目,我不在命令行工作,但我也嘗試了g ++ -pthread main.cpp,它給出了完全相同的錯誤。 請詳細說明或stepbystep解決方案,因爲您在這裏回答的一些問題對我來說只是中文。我只想讓一件簡單的事情運行,甚至不理解問題。甚至不明白那個錯誤信息,它要我做什麼。 基本上我做了:安裝eclipse,將上述內容寫入新項目,使用sinaptic pkg管理器安裝libboost 1.4,並重新啓動所有內容並嘗試編譯。我得到了錯誤。看不到發生了什麼,或者我錯過了什麼。 (我有libc-dev) 堆棧現在真的流淌了。需要一些睡眠來降溫。謝謝你們的幫助!
哇,那是我第一次聽說過Linux的稱爲Linux 10.10。毫無疑問,Ubuntu肯定會產生一些影響。 :-) – Shinnok 2011-03-22 10:58:43
對不起,我是新來的所有這些Linux和Ubuntu的東西,但是,是的,這是一個錯誤:)有趣,雖然 – andrissh 2011-03-22 11:15:03
顯示您的編譯命令行完全在你的問題。 Boost線程只是包裝底層的OS線程,所以通過包含boost/thread.hpp來請求pthreads。 – Duck 2011-03-22 13:14:31