I have been trying to get a simple c++ program running that was given to me as an example of multi-thread programming. I know it runs on another machine with boost installed, but I am trying to run it in Xcode, and this is giving me some problems.
First I tried to run it with my existing version of boost. However I was getting many errors and after doing some research, found that I needed to update my boost version from 1.47 to 1.52 to fix a few known threading bugs contained in 1.47.
That fixed many of my errors, but was still throwing a few. SO I found out that I had to patch 1.52 using the patch found here: https://svn.boost.org/trac/boost/attachment/ticket/7671/libcpp_c11_numeric_limits.patch
After all that, I am still getting a linker error saying "Library not found for -lboost_thread"
Right now in Xcode, I have the following project settings: Under search paths, I have the header and library search paths set to "usr/local/include/" - - Under linking I have other linker flags set to "-lboost_thread"
I have both a lboost_thread.a and a lboost_thread.dylib located in usr/local/lib/. How do I make xCode find this, as It seems that should fix my problem.
Also if it helps here is the code I am running:
#include <iostream>
#include <boost/thread.hpp>
using namespace std;
void printNum(char c, int num)
{
for(int i = 0; i < num; i++)
{
cout << c << i << endl;
}
}
int main()
{
cout << "Boost threads!" << endl;
boost::thread t(printNum, 'b', 100);
printNum('a', 100);
cout << "Good bye!" << endl;
}
Image of Error:
Image showing the file in it's location:
Image showing my build settings:
我不知道为什么链接器找不到库,但是我可以告诉您如何规避库搜索的问题:将完整路径/usr/local/lib/libboost_thread.a
添加到“其他链接器标志”构建设置中,不带-l或-L。
屏幕快照显示/usr/local/lib/libboost_thread.a
,建议使用-I/usr/local/lib/libboost_thread.a
也许就是这样。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.