Boost logo

Boost Users :

Subject: Re: [Boost-users] issues with unit tests on intel 32 bit, gcc 4.3, undefined reference to `__sync_fetch_and_add_4'
From: Maróy Ákos (akos_at_[hidden])
Date: 2009-04-14 10:11:41


Gennadiy,

>> I'm having an issue to link a boost unit test application on a Linux
>> box, which is 64 bit - but I want to create a 32 bit application.
>
> How did you build Boot.Test library? what variant r u using? Static or shared?

I compiled it the following way:

bjam architecture=x86 address-model=32 link=static runtime-link=static
--prefix=../../usr --includedir=../../usr/include --libdir=../../usr/lib
install

I'm trying to use the static version

> You should not use test_exec_monitor. You should link with
> boost_unit_test_framework.

linking only to boost_unit_test_framework gives the same results:

p$ make
g++ -m32 -L/home/maroy/src/tyrell/src/darksweep/usr/lib
-I/home/maroy/src/tyrell/src/darksweep/usr/include/boost-1_39 -o tests
tests.cpp -lboost_unit_test_framework-gcc43-mt-s
/home/maroy/src/tyrell/src/darksweep/usr/lib/libboost_unit_test_framework-gcc43-mt-s.a(framework.o):
In function
`boost::unit_test::framework::register_test_unit(boost::unit_test::test_suite*)':
framework.cpp:(.text+0x4a4): undefined reference to `__sync_fetch_and_add_4'
/home/maroy/src/tyrell/src/darksweep/usr/lib/libboost_unit_test_framework-gcc43-mt-s.a(framework.o):
In function
`boost::unit_test::framework::register_test_unit(boost::unit_test::test_case*)':
framework.cpp:(.text+0x648): undefined reference to `__sync_fetch_and_add_4'
framework.cpp:(.text+0x713): undefined reference to `__sync_fetch_and_add_4'
/home/maroy/src/tyrell/src/darksweep/usr/lib/libboost_unit_test_framework-gcc43-mt-s.a(framework.o):
In function `boost::unit_test::framework::get(unsigned long,
boost::unit_test::test_unit_type)':
framework.cpp:(.text+0x14fb): undefined reference to
`__sync_fetch_and_add_4'
/home/maroy/src/tyrell/src/darksweep/usr/lib/libboost_unit_test_framework-gcc43-mt-s.a(framework.o):
In function `boost::unit_test::framework::run(unsigned long, bool)':
framework.cpp:(.text+0x3151): undefined reference to
`__sync_fetch_and_add_4'
/home/maroy/src/tyrell/src/darksweep/usr/lib/libboost_unit_test_framework-gcc43-mt-s.a(framework.o):framework.cpp:(.text._ZN5boost9unit_test9framework11setup_errorC1ENS0_13basic_cstringIKcEE[boost::unit_test::framework::setup_error::setup_error(boost::unit_test::basic_cstring<char
const>)]+0x5c): more undefined references to `__sync_fetch_and_add_4' follow
collect2: ld returned 1 exit status
make: *** [tests] Error 1

> I'd suggest you to try to use single header variant of Boost.Test
> and thus avoid any linking issues.

hm, which would be...? this is my source code:

#include <boost/test/unit_test.hpp>

using namespace boost::unit_test;

test_suite *
init_unit_test_suite(int, char ** const) {
    test_suite *ts = BOOST_TEST_SUITE("test_suite");
    framework::master_test_suite().add(ts);

    return 0;
}

>> $ g++ --version
>> g++ (Ubuntu 4.3.2-1ubuntu12) 4.3.2
>> $ uname -a
>> Linux tomodachi 2.6.27-11-generic #1 SMP Wed Apr 1 20:53:41 UTC 2009
>> x86_64 GNU/Linux
>
> I can try to reproduce this. But I'll need to find vmware image for that.
> Do you know where i can find one?

this seems to be one:

Ubuntu 8.10 Desktop 64-Bit (amd64) VMWare Virtual Machine
http://www.mininova.org/tor/2013073

thanks for the help,

Akos


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net