std :: atomic <unsiged long =“”long =“”>:未定义引用`__atomic_fetch_add_8'</unsiged>

时间:2014-04-14 16:37:15

标签: c++ gcc c++11 g++

我正在尝试编译以下代码:

#include <atomic>
#include <iostream>
using namespace std;

int main() {
    atomic<unsigned long long> testull {0};
    testull++;
    cout << testull << endl;
    return 0;
}

g++48 --std=c++11 atomictest.cpp "-Wl,-rpath=/usr/local/lib/gcc48"

g++48因以下消息而失败:

/var/tmp//ccTBLlRL.o: In function `std::__atomic_base<unsigned long long>::fetch_add(unsigned long long, std::memory_order)':
atomictest.cpp:(.text._ZNSt13__atomic_baseIyE9fetch_addEySt12memory_order[_ZNSt13__atomic_baseIyE9fetch_addEySt12memory_order]+0x2e): undefined reference to `__atomic_fetch_add_8'
/var/tmp//ccTBLlRL.o: In function `std::__atomic_base<unsigned long long>::load(std::memory_order) const':
atomictest.cpp:(.text._ZNKSt13__atomic_baseIyE4loadESt12memory_order[_ZNKSt13__atomic_baseIyE4loadESt12memory_order]+0x2a): undefined reference to `__atomic_load_8'
collect2: error: ld returned 1 exit status

如果我将atomic<unsigned long long>更改为atomic<unsigned long>,那么它会毫无问题地编译。知道为什么吗?我在g++48

中使用FreeBSD 9.0

0 个答案:

没有答案