Pure virtual method - cross compilation

I am writing an event-based programming library for use on BeagleBone Black and have encountered a strange error.

When I compile the exact code with the same flags, I get the following errors on an ARM-based processor, but not when I run the code compiled for my x86 computer.

$ ./missionControl
pure virtual method called
pure virtual method called
pure virtual method called
terminate called recursively
terminate called recursively
Aborted

When I compile and run on my laptop, the program works correctly .

This is the command I use to compile (ish, I use Makefile, but both compilation methods show exactly the same behavior):

g++ -std=gnu++11 -pthread -O3 -D_GLIBCXX_USE_NANOSLEEP -o missionControl `find . -name *.cpp`

It doesn't matter if we cross-compile Ubuntu arm-linux-gnueabi-g++or ARM-compatible g++in real BeagleBone, I still get errors in ARM.

: , , ? , , g++?

!

backtrace ARM GDB:

#0  0xb6d4adf8 in raise () from /lib/libc.so.6
#1  0xb6d4e870 in abort () from /lib/libc.so.6
#2  0xb6f50ab4 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6
#3  0xb6f4ea4c in ?? () from /usr/lib/libstdc++.so.6
#4  0xb6f4ea4c in ?? () from /usr/lib/libstdc++.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
+4
3

- ARM libstd++, BeagleBone. , , ( " " ), std:: thread.

gcc/libstd++ 4.8 BeagleBone - .

+4

, , , , , , , , .

, , . , , , .

, .

+2

: https://groups.google.com/forum/#!topic/automatak-dnp3/Jisp_zGhd5I

: ++ 11 threading-fail clang 3.2?

Now I have no idea why this works, but this is for me at least. Add the following four preprocessor definitions to the compiler command line:

__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8

I have not experimented to make sure all of them are needed, or you can avoid some of them. But this solved the problem for me. Thanks to those who wrote the answers above, and thanks to my colleague for not starting me :)

+2
source

All Articles