2013-05-07 94 views
1

,当我尝试编译下面的代码的Ubuntu 12.04系统:的std :: atomic_thread_fence是未定义参考

#include <atomic> 
int a; 
int main() 
{ 
    a = 0; 
    std::atomic_thread_fence(std::memory_order_acquire); 
    a = 1; 
} 

我得到这样一个错误信息:

g++ test.cpp -std=c++0x 
/tmp/ccayKntC.o: In function `main': test.cpp:(.text+0x14): undefined reference to `std::atomic_thread_fence(std::memory_order)' collect2: ld returned 1 exit status 

clang++编译时会出现这种情况也。由于这是一个链接器错误,我猜我的libstdC++版本缺少必要的功能。但是,其他的原子操作似乎也行得通。

我使用的是Ubuntu 12.04。我想知道我的系统安装程序是否存在问题,无论是我的libstdC++中缺少的功能,还是其他可能的问题。理想情况下,我希望能够解决问题。

回答