FreeOrion

Forums for the FreeOrion project
It is currently Wed May 22, 2013 8:08 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: lib-dependencies on linux - to much
PostPosted: Wed Mar 05, 2008 3:36 pm 
Offline
Static Linker
User avatar

Joined: Thu Jun 28, 2007 10:28 am
Posts: 347
Hello there,

after a little discussion with Geoff the Medio and having some problems when building a statically linked version of FreeOrion for Linux, I tried to figure some things out. I think the actual situation does not allow most linux-users to run FreeOrion, as it is to complicated to build it.

Firstly, i took a look at the binaries. Dependencies of the binary after beeing compiled by scons are:
freerion 72 libs
freeriond 72 libs
freerionca 72 libs

Boah...
So I played around with gcc-options, and after adding -Wl,--as-needed to the command-line, there were only left:
freerion 67 libs
freeriond 35 libs
freerionca 38 libs

So, my first suggestion: add the parameter -Wl,--as-needed for linux-builds.

But this is still too much in my opinion! Somewhere deep inside the code there must be references to some libs, that are not needed at all but linked into the object at build-time. That causes problems, for it is almost impossible to run these binaries on any other system.

I know that this is related to some problems the Linker on unix-systems has, as it will not allow a binary to run without ALL dependecies fullfilled. I think some code would never be called or even some libs would be completely ignored, but I was not able to find out how to skip these dependencies for now.

The statically-linked binaries I produce with a script do not have that much dependencies:
freerion 18 libs
freeriond 4 libs
freerionca 8 libs (Python2.4 needs 5 libs)

That allows running freeoriond on root-servers without having to install many libs.
The 18 libs in freeorion are related to libGL and libGLU, as these libs need about 14 more libs.
freeorion-static needs:
Code:
ldd -u freeorion-static
        /usr/lib/libGL.so.1
        /usr/lib/libGLU.so.1
        /lib/libpthread.so.0
        /lib/libdl.so.2


Top
 Profile  
 
 Post subject: Re: lib-dependencies on linux - to much
PostPosted: Wed Mar 05, 2008 4:54 pm 
Offline
Compilation Expert
User avatar

Joined: Thu Jul 06, 2006 10:30 pm
Posts: 219
Location: Russia/Moscow
All freeorion's direct dependencies are genuinely required. If you want to decrease number of dependencies, your best bet is to disable unused features in dependency libs(DevIL, python, graphviz... they all have optional dependencies).

_________________
In Soviet Russia, forum posts YOU!!


Top
 Profile  
 
 Post subject: Re: lib-dependencies on linux - to much
PostPosted: Wed Mar 05, 2008 5:42 pm 
Offline
Static Linker
User avatar

Joined: Thu Jun 28, 2007 10:28 am
Posts: 347
You cannot expect that everybody is able to get this managed. I don't wan't to get tipps how to work around the problems. And it seems that you did not read my posting very well - there ARE unneeded dependencies which will be put into the resulting binary. That can easyly be reduced by adding the parameter I mentioned. And with some more work I think that even more dependencies can be removed.

For me its no problem getting FO running by now. But it indeed was VERY hard work, and I think I am a advanced developer who mostly knows what to do.

If this project is NOT interested in sharing FO in the future, than it's okay to say "your best bet is to disable unused features in dependency libs".


Top
 Profile  
 
 Post subject: Re: lib-dependencies on linux - to much
PostPosted: Wed Mar 05, 2008 7:50 pm 
Offline
Compilation Expert
User avatar

Joined: Thu Jul 06, 2006 10:30 pm
Posts: 219
Location: Russia/Moscow
kroddn wrote:
there ARE unneeded dependencies which will be put into the resulting binary.

Same set of -l* options is passed when compiling freeorion, freeoriond and freeorionca. Some -l's are needed e.g. by freeorion but not by freeorionca, but each -l is required by at least one of executables(unless it was added by pkg-config, in that case it is required by one of dependencies).

Passing only needed -l's for appropriate executables or passing -Wl,--as-needed won't give you any advantage if you're linking dynamically, so I assume that you want to use SCons build to link statically. Unfortunately I don't know an easy way to add -Wl,-static or -Wl,-dy before some -l's through SCons.

_________________
In Soviet Russia, forum posts YOU!!


Top
 Profile  
 
 Post subject: Re: lib-dependencies on linux - to much
PostPosted: Wed Mar 05, 2008 8:06 pm 
Offline
Static Linker
User avatar

Joined: Thu Jun 28, 2007 10:28 am
Posts: 347
Passing -wl,--as-needed does indeed make thinkgs better. It lets the compiler choose which libs not to include.

I don't think it will be possible to extend scons that it can build statically. I had to compile many libs by my own to support statical versions, e.v. boost, graphviz etc.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group