最近在arm环境下,编译程序运行时出现:
pure virtual method called
terminate called without an active exception
Aborted
的问题,查阅后,主要是由于编译工具链编译参数配置不正确导致的,解决方案编译时增加
-D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_{1,2,4}
的配置。具体为:
arm-oe-linux-gnueabi-g++ -std=c++11 -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_{1,2,4} test.cpp -o test -lpthread
或者
arm-oe-linux-gnueabi-g++ -c -std=c++11 -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 -D__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 test.cpp -o test -lpthread