Compiling in CentOS 5.4 - undefined reference to `__sync_bool_compare_and_swap_4'

Added by brocifer over 8 years ago

Hi folks,

I was wondering if anyone else has tried compiling under CentOS 5.4 x86. I've made some progress but have run into a wall with this error. Basically I'm getting a bunch of entries in my error log that say:

undefined reference to `__sync_bool_compare_and_swap_4'

A Google search yielded the suggestion to set CFLAGS="-march=i686" however, I'm still seeing the same error with or without modifying my CFLAGS. Anyone have an idea of how to fix this?

Here's the GCC packages I have installed currently:

gcc.i386 4.1.2-46.el5_4.2 installed
gcc-c++.i386 4.1.2-46.el5_4.2 installed
libgcc.i386 4.1.2-46.el5_4.2 installed

For reference, these are the equivalent RPM packages required to compile that I've come up with so far (or so I thought):

libxml2-devel
gcc-c++
libtool
automake
autoconf
libpng-devel
libjpeg-devel
rrdtool
libmysql-devel
bison

I attempted to yank gcc-c++ ver. 4.1.2 and replace it with 4.4, but thus far I've been unable to get gcc 4.4 to compile C++ executables at all. Any suggestions would be most welcome.


Replies (9)

RE: Compiling in CentOS 5.4 - undefined reference to `__sync_bool_compare_and_swap_4' - Added by vl over 8 years ago

You are the second one to have this.

We applied a fix but it seems that we need a more accurate test to use this function or not.

To fix it, open include/nel/misc/mutex.h and comment line 247 and uncomment line 246 and also uncomment the block line 112 to 133.

Then recompile everything (nel, nelns, client, server...) :/

RE: Compiling in CentOS 5.4 - undefined reference to `__sync_bool_compare_and_swap_4' - Added by brocifer over 8 years ago

Thanks a lot for the feedback, do I still need to specify -march in CFLAGS for this to work?

Cheers

RE: Compiling in CentOS 5.4 - undefined reference to `__sync_bool_compare_and_swap_4' - Added by brocifer over 8 years ago

So, your earlier feedback proved helpful. After making the suggested adjustments, I'm no longer running into the undefined reference issues and it's definitely moving along further. I'm now stuck on something I suspect is related to the libmysqlclient or there may be something else I'm not seeing here.

If you grep through the make error log for:

"shared_unifier_service"

you'll see it's preceded by:

/usr/bin/ld: cannot find -lmysqlclient

I'm not actually sure if this is what is causing the errors, but it definitely looks suspect. I've attached my error log in case you or anyone else has a moment to take a look. I was half wondering if maybe it's just a difference in the library names?

Here's where my libmysqlclient libs reside:

/usr/lib/mysql/libmysqlclient.a
/usr/lib/mysql/libmysqlclient.so
/usr/lib/mysql/libmysqlclient.so.15
/usr/lib/mysql/libmysqlclient.so.15.0.0
/usr/lib/mysql/libmysqlclient_r.a
/usr/lib/mysql/libmysqlclient_r.so
/usr/lib/mysql/libmysqlclient_r.so.15
/usr/lib/mysql/libmysqlclient_r.so.15.0.0

Beyond that, if there's anything else that looks out of the ordinary I am having a difficult time tracking it down.

make_all_error.zip - make_all_error.log (279.8 kB)

RE: Compiling in CentOS 5.4 - undefined reference to `__sync_bool_compare_and_swap_4' - Added by vl over 8 years ago

/usr/lib/mysql/libmysqlclient.* should be in /usr/lib/libmysqlclient.*

since it's in a sub directory, you have to add the subdirectory in the server/server/shard_unifier/Makefile with something like -L/usr/lib/mysql/

RE: Compiling in CentOS 5.4 - undefined reference to `__sync_bool_compare_and_swap_4' - Added by grego over 8 years ago

Just for fun I'm trying to build it on CentOS 5.4 as well and hit a snag. I made the adjustments listed above to avoid the compare_and_swap errors and now my build fails on Ryzom Makefile (where before it would fail well into Ryzom):

/home/greg/code/ryzom/../../code/nel/include/nel/misc/mutex.h:245:6: error: invalid preprocessing directive #result

I am attaching the full error log as well.

Thanks,
-G

RE: Compiling in CentOS 5.4 - undefined reference to `__sync_bool_compare_and_swap_4' - Added by rti over 8 years ago

Hmm. Seems like you have mixed up something while changing mutex.h?
gcc is right, #result is not a preprocessing directive. But a variable is called like that in the code.

You may as well revert your changes in mutex.h. Check #899 how to handle the compare_and_swap linker error. (In short: make sure you are compiling with at least -march=i486)

RE: Compiling in CentOS 5.4 - undefined reference to `__sync_bool_compare_and_swap_4' - Added by brocifer over 8 years ago

There's actually another couple problems I failed to mention that I've just been fixing manually in the hopes of finding a process that works.

From a base clone, here are the manual fixes I've been applying while compiling under CentOS:

1.) ../../include/nel/misc/static_map.h:148: error: expected `;' before 'return' (I'm just going in and fixing the missing ';')

2.) ../../include/nel/misc/mutex.h and comment line 247 and uncomment line 246 and also uncomment the block line 112 to 133

3.) Finally, there's an issue that I've been using a workaround to fix, but might also be relevant. There's a syntax error being thrown by:

/root/ryzom/code/nelns/configure on line 19448

I haven't had much time to look into it, but I think autoconf is screwing something up. You'll notice a mangled greater than symbol in that expression on line 19448:

\>\=

Since the file is auto generated, and frankly I haven't had the time or knowledge to trace down how it's being made I've just been manually fixing it. I do this by beginning to compile until the configure file is generated and then breaking out and manually fixing it, then restarting the compile a second time. By the way, is there any kind of make clean? Also, is there a better fix than my poor-man's solution?

_____________________________________
You may as well revert your changes in mutex.h. Check #899 how to handle the compare_and_swap linker error. (In short: make sure you are compiling with at least -march=i486)

rti,

Thanks! I just looked at the bug, I'll try reverting my changes to mutex.h and ensuring I set CXXFLAGS. Will report back on my progress later today. If anyone has any experience with the other errors I've touched on, I'd be very grateful for any insights.

RE: Compiling in CentOS 5.4 - undefined reference to `__sync_bool_compare_and_swap_4' - Added by grego over 8 years ago

Ok - so my error was my fault, stupid me used a hash instead of // to comment out a line. Recompiling now after making apropriate changes and updating some paths.

(1-9/9)