Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/163.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在cygwin中使用boost::thread编译一个简单的程序? 我安装了CygWin的Boost包,并有一个目录/Ur/IsPo/Boost,其中包括一组*.HPP文件,包括thul.Hpp,我需要通过C++文件来包含在C++文件中 #include <boost/thread.hpp>_C++_Multithreading_Boost_Cygwin - Fatal编程技术网

如何在cygwin中使用boost::thread编译一个简单的程序? 我安装了CygWin的Boost包,并有一个目录/Ur/IsPo/Boost,其中包括一组*.HPP文件,包括thul.Hpp,我需要通过C++文件来包含在C++文件中 #include <boost/thread.hpp>

如何在cygwin中使用boost::thread编译一个简单的程序? 我安装了CygWin的Boost包,并有一个目录/Ur/IsPo/Boost,其中包括一组*.HPP文件,包括thul.Hpp,我需要通过C++文件来包含在C++文件中 #include <boost/thread.hpp>,c++,multithreading,boost,cygwin,C++,Multithreading,Boost,Cygwin,我的g++编译命令应该是什么样子?我知道我应该使用一些-L-I和-L的组合,但我不确定每个参数应该提供什么,到目前为止,没有任何东西对我有效 我尝试了以下方法: $ g++ test.cpp -lboost_thread-gcc-mt /cygdrive/c/Users/jonderry/AppData/Local/Temp/ccaNCMaA.o:test.cpp:(.text$_ZN5boost6detail11thread_dataIPFvvEED 0Ev[boost::detail::th

我的g++编译命令应该是什么样子?我知道我应该使用一些-L-I和-L的组合,但我不确定每个参数应该提供什么,到目前为止,没有任何东西对我有效

我尝试了以下方法:

$ g++ test.cpp -lboost_thread-gcc-mt
/cygdrive/c/Users/jonderry/AppData/Local/Temp/ccaNCMaA.o:test.cpp:(.text$_ZN5boost6detail11thread_dataIPFvvEED
0Ev[boost::detail::thread_data<void (*)()>::~thread_data()]+0x16): undefined reference to `boost::detail::thre
ad_data_base::~thread_data_base()'
...
...
$g++test.cpp-lboost\u thread-gcc-mt
/cygdrive/c/Users/jonderry/AppData/Local/Temp/ccaNCMaA.o:test.cpp:(.text$_ZN5boost6detail11thread_dataIPFvvEED
0Ev[boost::detail::thread_data::~thread_data()]+0x16):未定义对“boost::detail::thre”的引用
ad_数据库::~thread_数据库()
...
...

编辑(删除-gcc部分):
g++sample.cpp-lboost\u thread-mt
。您可能还需要添加
-lpthread
-pthread
。如果仍然不走运,请张贴错误。HTH

安装软件包时没有同时安装预建库吗?可能,但我找不到。目录/usr/include/boost只包含一堆hpp文件。/usr/include用于标题。lib在其他地方,可能在/usr/lib、/usr/local/lib或/usr/share/lib中——我不知道cygwin的确切位置。如果其中没有一个包含它们,
find/usr-name“libboost”
会有帮助:)好的,我添加了一些细节并改进了问题。谢谢推进1.33.1?那太老了!当时Boost.Thread可能在cygwin支持方面遇到了一些问题。您可以尝试更新的版本吗?问题已更新为错误输出。我也尝试了-lpthread和-pthread,但结果是一样的(-pthread是一个无法识别的选项)@jonderry:square。
-lboost\u thread-mt
(不带-gcc)工作得更好吗?@jonderry:很高兴它起到了作用。无论如何,下面是Boost的更改历史记录。线程:
$ g++ test.cpp -lboost_thread-gcc-mt
/cygdrive/c/Users/jonderry/AppData/Local/Temp/ccaNCMaA.o:test.cpp:(.text$_ZN5boost6detail11thread_dataIPFvvEED
0Ev[boost::detail::thread_data<void (*)()>::~thread_data()]+0x16): undefined reference to `boost::detail::thre
ad_data_base::~thread_data_base()'
...
...