【问题标题】:Boost C++ libraries for gcc-arm toolchain用于 gcc-arm 工具链的 Boost C++ 库
【发布时间】:2010-09-19 11:41:11
【问题描述】:

我在 timesys arm-gcc 工具链上构建 1.35.0 和 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;
}

我收到以下链接器错误:


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

有谁知道如何让 Boost 为 gcc-arm 工具链构建?

【问题讨论】:

    标签: c++ gcc boost arm


    【解决方案1】:

    在 Boost 邮件列表中,here 回答了几乎相同的问题。

    【讨论】:

      【解决方案2】:

      您需要在文件'boost_1_35_0/boost/config/user.hpp'中添加:

      #define BOOST_SP_USE_PTHREADS
      

      顺便说一句,您需要将文件 'boost_1_35_0/tools/build/v2/user-config.jam' 中的 gcc 工具链设置为:

      using gcc
              : arm
              : /opt/timesys/at91sam9263_ek/toolchain/bin/armv5l-timesys-linux-gnueabi-gcc
      ;
      

      这将解决现在链接的问题。

      【讨论】:

        猜你喜欢
        • 2014-05-29
        • 2013-06-20
        • 2021-06-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-06-10
        • 2011-08-23
        相关资源
        最近更新 更多