linux下编译boost的多线程程序
来源:互联网 发布:知乎网络小说推荐 编辑:程序博客网 时间:2024/06/05 09:40
linux下面用boost库进行多线程编程,一开始总是编译不成功,花了好多的时间。
下面是一段小示例代码:
//start from the very beginning,and to create greatness//@author: Chuangwei Lin//@E-mail:979951191@qq.com//@brief: boost多线程编译的示例#include <boost/thread.hpp>#include <iostream>void lcw1(){ std::cout << "lcw1 is working!" << std::endl;}void lcw2() { std::cout << "lcw2 is working!" << std::endl;}int main (int argc, char ** argv){ using namespace boost; thread thread_1 = thread(lcw1); thread thread_2 = thread(lcw2); thread_2.join(); thread_1.join(); return 0;}
编译命令如下;
g++ -I /usr/local/inlcude -L /usr/lib lcw.cpp -lboost_system -lboost_thread -o lcw
上述的编译命令要包含库的路径还有链接库的名称,不然编译无法通过
(之前脑残忘记是c++然后一直用gcc编译。。。。。)
但是,虽然编译成功,还是出现如下的问题:
那就表示系统不知道xxx.so放在哪个目录下,这个时候就要在/etc/ld.so.conf中加入xxx.so所在的目录,我们先前安装的时候是把.so文件都搬到了/usr/lib里面,所以在/etc/ld.so.conf中加入/usr/lib这一行,可以解决此问题。将/etc/ld.so.conf存档后,还要执行/etc/ldconfig 来更新一下才会生效。最后终于可以执行,结果如下;
1 0
- linux下编译boost的多线程程序
- linux下编译boost的多线程程序
- Linux下G++怎么编译使用Boost库的程序
- linux下编译boost
- linux下编译BOOST
- linux下编译boost
- linux 下boost编译
- linux 下编译boost
- linux下编译boost
- boost linux下编译
- linux下boost编译
- linux 下编译 boost 的笔记
- boost程序的编译
- Linux下boost编译安装
- linux下编译boost.python
- boost在linux下编译
- Linux 下编译使用Boost
- Linux下编译安装BOOST
- 社会媒体中的谣言分析框架(IEEE2011)
- 关于HashSet、TreeSet、LinkedHashSet的区别
- mqtt,Could not connect: CONNECTION_REFUSED_NOT_AUTHORIZED
- c++下halcon配置
- LeetCode[链表] - #21 Merge Two Sorted Lists
- linux下编译boost的多线程程序
- C++中的static关键字
- 算法导论第三版-课后习题-自解
- 文章标题
- 总结Android UI 自动化测试
- 字符串和编码
- HDU Cut Pieces (计数+求逆元)
- Android debug.keystore的密码
- ionic + angularJS $ionicHistory接口文档