Help! Boost.asio compilation problem: undefined reference to `__sync_add_and_fetch_8

Hey guys, This could be a noob question, but I really can't find any useful solution through Google. I'm testing a hello world with boost.asio, the program is quite simple:

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
int main()
{
  boost::asio::io_service io;
  boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
  t.wait();
  std::cout << "Hello, world!\n";
  return 0;
}

I passed the compilation and run well on my Intel Pentium PC (Ubuntu 10.10, gcc 4.4.5, Boost 1.46.0). The command line I used was g++ -o a a.cpp -I /Boost-Include-Path/ -L /Boost-lib-Path/ -lboost_system. But when I compile the same code on another machine(which is a big one, I'll explain it later), it can't pass the compilation and gives such errors:

/tmp/ccOZxZBX.o: In function boost::asio::detail::gcc_sync_fenced_block::gcc_sync_fenced_block()': a.cpp:(.text._ZN5boost4asio6detail21gcc_sync_fenced_blockC1Ev[boost::asio::detail::gcc_sync_fenced_block::gcc_sync_fenced_block()]+0x4c): undefined reference to__sync_lock_test_and_set_4' /tmp/ccOZxZBX.o: In function boost::detail::atomic_count::operator++()': a.cpp:(.text._ZN5boost6detail12atomic_countppEv[boost::detail::atomic_count::operator++()]+0x30): undefined reference to__sync_add_and_fetch_8' /tmp/ccOZxZBX.o: In function boost::detail::atomic_count::operator--()': a.cpp:(.text._ZN5boost6detail12atomic_countmmEv[boost::detail::atomic_count::operator--()]+0x30): undefined reference to__sync_add_and_fetch_8' /tmp/ccOZxZBX.o: In function boost::detail::atomic_count::operator long() const': a.cpp:(.text._ZNK5boost6detail12atomic_countcvlEv[boost::detail::atomic_count::operator long() const]+0x30): undefined reference to__sync_fetch_and_add_8'

The machine I used was a SiCortex SC5832,which use MIPS64 instruction set processors, OS is changed CentoOS. Gcc 4.2.3, Boost1.46.0. Is it possible that there are problems about the compatibility of the MIPS? I added -mips64 option, but it still give the same errors. I know this environment could not be very usual, but I think some people who are using similar big machines may face the same problem.

Any help would be appreciated. By the way, I don't have sudo permission.

Thanks, Tony
These sorts of questions about third-party C++ libraries are always best directed to the specific library's support resources. In this case, the Boost Users email list is the best place to start.

http://www.boost.org/community/groups.html
Thanks!
Actually, ++sync_fetch_and_add and its various flavors are supposed to be compiler intrinsics specific to gcc. It almost sounds like that isn't supported on your particular hardware, or perhaps you need to link against another library. I'd start by looking at gcc documentation, though perhaps some boost users have already come across this problem and have a solution.
oh, hardware not supported,that's really bad.
But thanks anyway.
Topic archived. No new replies allowed.