构建1.35.0以及在timesys arm-gcc工具链上的1.36.0,无论是静态(链接静态)还是动态(.so,默认选项)都没有问题.
但是,当我尝试链接一个简单的示例文件系统应用程序时:
#include <boost/filesystem.hpp>
#include <iostream>
namespace fs = boost::filesystem;
int main(int argc, char *argv[]) {
const char* fileName = argv[1];
std::cout << "file: " << fileName << " => " << fs::exists(fileName) << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我收到以下链接器错误:
developer@eldp01:~/boost/test$ /opt/timesys/at91sam9263_ek/toolchain/bin/armv5l-timesys-linux-gnueabi-gcc
exists.cpp -o exists.exe -I ../boost_1_35_0/ -lboost_filesystem -lboost_system -lstdc++ -L .
/tmp/ccex3NGb.o: In function `boost::detail::atomic_decrement(int*)':
exists.cpp:(.text._ZN5boost6detail16atomic_decrementEPi[boost::detail::atomic_decrement(int*)]+0x1c):
undefined reference to `__sync_fetch_and_add_4'
/tmp/ccex3NGb.o: In function `boost::detail::atomic_increment(int*)':
exists.cpp:(.text._ZN5boost6detail16atomic_incrementEPi[boost::detail::atomic_increment(int*)]+0x1c):
undefined reference to `__sync_fetch_and_add_4'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
有谁知道如何让我的Boost为gcc-arm工具链构建?
您需要在文件“boost_1_35_0/boost/config/user.hpp”中添加:
#define BOOST_SP_USE_PTHREADS
Run Code Online (Sandbox Code Playgroud)
顺便说一句,您需要将文件“boost_1_35_0/tools/build/v2/user-config.jam”中的 gcc 工具链设置为:
Run Code Online (Sandbox Code Playgroud)using gcc : arm : /opt/timesys/at91sam9263_ek/toolchain/bin/armv5l-timesys-linux-gnueabi-gcc ;
这将解决现在的链接问题。
归档时间: |
|
查看次数: |
7027 次 |
最近记录: |