Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost C++ libraries for gcc-arm toolchain

Tags:

c++

gcc

boost

arm

I have no trouble building 1.35.0, as well as 1.36.0 on the timesys arm-gcc toolchain, both statically (link-static) as well as dynamically (.so, default option).

However, when I try to link a simple sample filesystem app:

#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;
}

I get the following linker error:


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

Does anyone know how I can get Boost to build for the gcc-arm toolchain?

like image 473
TheSeeker Avatar asked Oct 27 '08 22:10

TheSeeker


People also ask

Does Boost support C ++ 17?

Container not only supports this model with C++11 but also backports it to C++03 via boost::container::allocator_traits including some C++17 changes. This class offers some workarounds for C++03 compilers to achieve the same allocator guarantees as std::allocator_traits .

What is Boost library C ++ 11?

Boost is a set of libraries for the C++ programming language that provides support for tasks and structures such as linear algebra, pseudorandom number generation, multithreading, image processing, regular expressions, and unit testing.

How do I install Boost library?

Install Boost (Windows)Download the source code from http://www.boost.org/users/download/. Extract in a Boost folder located at C:\ or C:\Program files so that CMake find-modules can detect it. Invoke the command line and navigate to the extracted folder (e.g. cd C:\Boost\boost_1_63_0 ).


2 Answers

An almost identical question was answered here on the Boost mailing list.

like image 87
ChrisN Avatar answered Oct 20 '22 09:10

ChrisN


You need to add in file 'boost_1_35_0/boost/config/user.hpp':

#define BOOST_SP_USE_PTHREADS

btw, you need to set the gcc tool-chain in file 'boost_1_35_0/tools/build/v2/user-config.jam' to:

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

This will solve the problem of linking now.

like image 3
TheSeeker Avatar answered Oct 20 '22 10:10

TheSeeker