Whenever I try to use __sync_fetch_and_add with -m32 on a 64 bit machine, I get the following error, while it compiles fine with normal 64 bit. I am using gcc compiler 4.1.2. What can be the problem here and what is the solution?
replication.cpp:(.text+0xb3b): undefined reference to `__sync_fetch_and_add_4' replication.cpp:(.text+0xb82): undefined reference to `__sync_fetch_and_add_4' replication.cpp:(.text+0xcc2): undefined reference to `__sync_fetch_and_add_4' /tmp/cc7u9FLV.o: In function `potential_barrier_leader(unsigned int, pthread_barrier_t*)': replication.cpp:(.text+0xd3f): undefined reference to `__sync_fetch_and_add_4' replication.cpp:(.text+0xd54): undefined reference to `__sync_fetch_and_add_4' /tmp/cc7u9FLV.o:replication.cpp:(.text+0xdb0): more undefined references to `__sync_fetch_and_add_4' follow collect2: ld returned 1 exit status make: *** [all] Error 1
Advertisement
Answer
Using -march=i486 flag did the trick for me.