如何使用boost ::线程的cygwin编译一个简单的程序? [英] How do compile a simple program using boost::thread in cygwin?

查看:175
本文介绍了如何使用boost ::线程的cygwin编译一个简单的程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装cygwin的版本升压封装,有一个目录/ usr / include目录/升压,包括一堆* .HPP文件,包括thread.hpp,我需要在C ++文件包括,通过

 的#include<升压/ thread.hpp>

此外,几个* .a文件似乎提高::线程是相关的。

  $ LS / usr / lib目录/ libboost_thread * -1
/usr/lib/libboost_thread-gcc-mt-1_33_1.a
/usr/lib/libboost_thread-gcc-mt.a
/usr/lib/libboost_thread-mt.a
/usr/lib/libboost_thread-mt.dll.a

我应该我的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 ::详细:: thread_data<无效(*)()> ::〜thread_data()] + 0x16):未定义的引用`提振::详细:: THRE
ad_data_base ::〜thread_data_base()
...
...


解决方案

编辑(删除-gcc部分): G ++ sample.cpp的-lboost_thread-MT 。您可能需要添加 -lpthread -pthread 为好。如果仍然没有运气,请发表你的错误。 HTH

I installed the boost package from cygwin and have a directory /usr/include/boost that includes a bunch of *.hpp files, including thread.hpp, which I need to include in the c++ file, via

#include <boost/thread.hpp>

Also, several *.a files seem to be related to boost::thread.

$ ls /usr/lib/libboost_thread* -1
/usr/lib/libboost_thread-gcc-mt-1_33_1.a
/usr/lib/libboost_thread-gcc-mt.a
/usr/lib/libboost_thread-mt.a
/usr/lib/libboost_thread-mt.dll.a

What should my g++ compilation command look like? I understand I should be using some combination of -L -I, and -l, but I'm not sure what to supply for each argument, and nothing is working for me so far.

I have tried the following:

$ 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()'
...
...

解决方案

EDIT (removed -gcc part): g++ sample.cpp -lboost_thread-mt. You may need to add -lpthread or -pthread as well. If still no luck, please post the errors you get. HTH

这篇关于如何使用boost ::线程的cygwin编译一个简单的程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆