I have the following program:
~/test> cat test.cc int main() { int i = 3; int j = __sync_add_and_fetch(&i, 1); return 0; }
I am compiling this program using GCC 4.2.2 for Linux, running on an Intel 64-bit machine with several processors:
~/test> uname --all Linux doom 2.6.9-67.ELsmp
When I compile a program in 64-bit mode, it compiles and binds a fine:
~/test> /share/tools/gcc-4.2.2/bin/g++ test.cc ~/test>
When I compile it in 32-bit mode, I get the following error:
~/test> /share/tools/gcc-4.2.2/bin/g++ -m32 test.cc /tmp/ccEVHGkB.o(.text+0x27): In function `main': : undefined reference to `__sync_add_and_fetch_4' collect2: ld returned 1 exit status ~/test>
Although I will never run on a 32-bit processor, I need a 32-bit executable, so I can link it to 32-bit libraries.
My 2 questions:
gcc atomic linker
Cayle Spandon Sep 25 '08 at 0:11 2008-09-25 00:11
source share