C ++ undefined reference to `__atomic_load_16 '

I have error binding when trying to execute atomic load of a 16 byte block. I have the following code:

#include <atomic>

struct MyStruct{
  long x; long y;
};

struct X{
  std::atomic<MyStruct> myStruct;
};

int main(){
  X x;
  MyStruct s = atomic_load(&x.myStruct);
}

When I compile this with (g ++ version 5.3.1):

g++ --std=c++11 test.cpp

I get an error

/tmp/ccrvzLMq.o: In function `std::atomic<MyStruct>::load(std::memory_order) const':
test.cpp:(.text._ZNKSt6atomicI8MyStructE4loadESt12memory_order[_ZNKSt6atomicI8MyStructE4loadESt12memory_order]+0x1c): undefined reference to `__atomic_load_16'
collect2: error: ld returned 1 exit status

If (after a hint in another post), I add the "-latomic" flag, I get the error "/ bin / ld: cannot find / usr / lib 64 / libatomic.so.1.1.0". And indeed, this file does not exist.

Any suggestions?

Gavin

+4
source share

All Articles