• Advertisement
Sign in to follow this  

Compiling GLIBC on Linux. Oh golly gosh!

This topic is 2543 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to compile my game on Linux. It works find on my Ubuntu system, but when I send the compiled binary off to my buddy with Centos it won't run. It complains saying:


/lib64/libc.so.6: version `GLIBC_2.7' not found
/lib64/libc.so.6: version `GLIBC_2.11' not found
/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found
/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found

I've googled around the place and it seems that because I compiled on my new computer it's not going to work on his old computer. Whereas if I'd compiled on an old computer it would've worked fine on both. Crazy old Linux! He only has GLIBC_2.5 on his Centos machine, whereas I have 2.11. What I'd like though is for my binary to run on as many installations as possible. I really don't want to have to set up a whole new installation with an old version of GLIBC just to recompile it again. So first of all, can I force my project to compile at the lowest level of GLIBC possible? Or at the very least, how do I remove these symbols (from running: objdump -T MYGAME):

GLIBC_2.4 __stack_chk_fail
GLIBC_2.7 __isoc99_sscanf
GLIBC_2.11 __longjmp_chk
GLIBCXX_3.4.11 _ZNKSt5ctypeIcE13_M_widen_initEv
GLIBCXX_3.4.9 _ZNSo9_M_insertIbEERSoT_
GLIBCXX_3.4.9 _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
GLIBCXX_3.4.9 _ZNSo9_M_insertImEERSoT_
GLIBCXX_3.4.9 _ZNSo9_M_insertIdEERSoT_
GLIBCXX_3.4.9 _ZNSi10_M_extractIfEERSiRT_


My understanding is that if I remove these symbols from my code/project then it'll run fine on my buddies computer. Of course ideally, if there's a way to support even lower than that this would be awesome. So what's the best course of action here? Is there some compiler option to automatically support the oldest versions of GLIBC and GLIBCXX? Or maybe I have to manually go through and weed all these symbols out (also probably through some compiler options).. or maybe I need to statically link against libc.so.6 and libstdc++.so.6?

Anyway, any help would be greatly appreciated :D
Cheers,
Ben.

Share this post


Link to post
Share on other sites
Advertisement
Not every Linux distro is the same. Hence the reason why every distro has their own package manager and it's own set up packaged versions.

Share this post


Link to post
Share on other sites
On Linux it's often much easier to just give the source code to the user so he can compile it himself.

Share this post


Link to post
Share on other sites

every distro has their own package manager


Uhm ...

There are only two "mainstream" packaging systems, debs and rpms. And in many cases, carefully stuffed packages install on many distros that understand the package in question. The last deb I've personally distributed e.g. would install on at least Ubuntus 10.x, Debians 5.x, Mint and gNewSense (others not tested).



O.P.: Maybe ELF Statifier could be of interest to you, though it completely circumvents the whole idea behind package managers. An extravagant idea could also be to setup a virtualbox-image :D

Share this post


Link to post
Share on other sites
Here you go:
http://ldn.linuxfoundation.org/lsb/build-lsb-compliant-application

If you intend to do cross distribution binary only applications the LSB is your best friend.

Share this post


Link to post
Share on other sites
Hidden
Here you go:
http://ldn.linuxfoundation.org/lsb/build-lsb-compliant-application

If you intend to do cross distribution binary only applications the LSB is your best friend.

Share this post


Link to post
A third alternative you could consider is to build your game statically.

You get this exact same problem on Microsoft Windows. Often times application vendors work around simply by shipping all the runtimes with their app (eg. MSVCRT.DLL and friends).

Share this post


Link to post
Share on other sites
Thanks for all the suggestions guys :D

Katie, thx for that massive reply. I think I might set up a chroot environment. Can you reccomend a good distrbution to target the lowest level possible (for maximum compatibility)?

Share this post


Link to post
Share on other sites
Centos, RHEL, SLES and some other distros intended for 'enterprise' type machines have relatively old (aka 'stable') versions of most software compared to something like Ubuntu so you have to be aware of that if you intend to distribute binaries.

Share this post


Link to post
Share on other sites
So, I could be wrong here, but did you try checking to see whether he is running a 32-bit install? Its obvious that you are running a 64-bit install...is it possible he has a 32?

Share this post


Link to post
Share on other sites
He has 64 bit. But that's another good point.. obviously I want my game to be playable on both 32 and 64 bit installations. What's the best way to deal with this? Is it possible to create 1 binary that will work on both? Or do I need to build 2 separate binaries?

Share this post


Link to post
Share on other sites

He has 64 bit. But that's another good point.. obviously I want my game to be playable on both 32 and 64 bit installations. What's the best way to deal with this? Is it possible to create 1 binary that will work on both? Or do I need to build 2 separate binaries?
Create an LSB-compliant 32-bit binary, make sure your program depends on the proper 32-bit packages. Unless you're going to use 2+ gigs of RAM, there's no point in also creating a 64-bit binary.

Share this post


Link to post
Share on other sites
Hmm ok. So can I create 32 bit chroot environment and compile within that? Any suggestions? Or do I need to add some compiler flag to make it 32bit (I'm on a 64bit machine).

Share this post


Link to post
Share on other sites

[quote name='bencelot' timestamp='1296870928' post='4769848']
He has 64 bit. But that's another good point.. obviously I want my game to be playable on both 32 and 64 bit installations. What's the best way to deal with this? Is it possible to create 1 binary that will work on both? Or do I need to build 2 separate binaries?
Create an LSB-compliant 32-bit binary, make sure your program depends on the proper 32-bit packages. Unless you're going to use 2+ gigs of RAM, there's no point in also creating a 64-bit binary.
[/quote]

Except all those additional juicy registers and a better ABI, and SSE2 minspec. No reason at all :)

Share this post


Link to post
Share on other sites

[quote name='valderman' timestamp='1296905086' post='4769956']
[quote name='bencelot' timestamp='1296870928' post='4769848']
He has 64 bit. But that's another good point.. obviously I want my game to be playable on both 32 and 64 bit installations. What's the best way to deal with this? Is it possible to create 1 binary that will work on both? Or do I need to build 2 separate binaries?
Create an LSB-compliant 32-bit binary, make sure your program depends on the proper 32-bit packages. Unless you're going to use 2+ gigs of RAM, there's no point in also creating a 64-bit binary.
[/quote]

Except all those additional juicy registers and a better ABI, and SSE2 minspec. No reason at all :)
[/quote]Then it's better to just compile a second binary with -msse2. As demonkoryu says, more registers and fancier instructions do nothing for you if you hit RAM all the time. Add in the porting issues you get for using a low-level language and maintaining two binaries suddenly seems a lot less attractive.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement