Boost logo

Boost Users :

Subject: Re: [Boost-users] undefined reference to '__sync_add_and_fetch_4' when cross-compiling boost::asio fors mips
From: Andreas Wehrmann (a.wehrmann_at_[hidden])
Date: 2012-02-17 02:01:48


On 02/16/2012 10:06 AM, Jayne wrote:
>
> Hello,
>
> I'm trying to build Boost 1.48.0 for use with the WebSockets++ library
> on a MIPS based embedded Linux board.
>
> My build machine reports itself as: Linux version 2.6.40.4-5.fc15.x86_64
> (mockbuild_at_[hidden]) (gcc version 4.6.0 20110603
> (Red Hat 4.6.0-10) (GCC) ) #1 SMP Tue Aug 30 14:38:32 UTC 2011
>
> My cross-compiler version is: mipsel-linux-g++ (GCC) 4.2.0 20070124
> (prerelease) - BRCM 11ts-20090508. I don't have any control over this as
> its provided by the chip manufacturer.
>
> I can build Boost without any reported errors and can link to and use
> most of the libraries without any problems. However, when WebSockets
> tries to link to the Boost::asio library I get link errors like this:
>
> (.gnu.linkonce.t._ZNSt5dequeIN5boost13intrusive_ptrIN11websocketpp7message4dataEEESaIS5_EE16_M_push_back_auxERKS5_+0x30):
> undefined reference to `__sync_add_and_fetch_4'
>
> (.gnu.linkonce.t._ZNSt5dequeIN5boost13intrusive_ptrIN11websocketpp7message4dataEEESaIS5_EE16_M_push_back_auxERKS5_+0x80):
> undefined reference to `__sync_add_and_fetch_4'
>
> (.gnu.linkonce.t._ZN11websocketpp9processor4hybiINS_10connectionINS_8endpointINS_4role6serverENS_6socket5plainENS_3log6loggerEEENS5_ISA_E10connectionENS7_ISA_E10connectionEEEE19prepare_close_frameEN5boost13intrusive_ptrINS_7message4dataEEENS_5close6status5valueERKSs+0xc8):
> more undefined references to `__sync_add_and_fetch_4' follow
>
> I've done enough research to find this has been a problem in the past
> with ARM chips and is to do with atomic transactions not being
> implemented by gcc for the target machine. I've tried the suggested
> fixes for ARM which were to build with either BOOST_SP_DISABLE_THREADS
> or BOOST_SP_USE_PTHREADS but that didn't help with my MIPS environment.
>
> Can anyone make any suggestions as to what I could try next?
>
> thanks,
>
> Jayne.
>

Try this #define:

BOOST_ASIO_DISABLE_FENCED_BLOCK

-- 
Dipl.-Ing. (FH) Andreas Wehrmann
Software Development
--------------------------------------------------------------
Center Communication Systems GmbH
A-1210 Wien, Ignaz-Köck-Straße 19
Sitz in Wien
FN 796 88p, Firmenbuchgericht Wien
www.centersystems.com
Tel.: +43 (0) 190 199 - 3616
Mobile: +43 (0) 664 884 75916
Fax: +43 (0) 190 199 - 2110
E-Mail: a.wehrmann_at_[hidden]

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