LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-19-2015, 09:21 AM   #1
teapottwo
Member
 
Registered: Sep 2013
Posts: 52

Rep: Reputation: Disabled
Static Libraries


Hey,

I'm using the Irrlicht Engine (http://irrlicht.sourceforge.net/) and am after building it into my application statically.

All I've really done is add the following to the makefile:
Code:
-static-libgcc -static-libstdc++ -static
The errors shown are:
Quote:
/usr/bin/ld: cannot find -lGL
/usr/bin/ld: cannot find -lXxf86vm
/usr/bin/ld: cannot find -lXext
/usr/bin/ld: cannot find -lX11
/usr/bin/ld: cannot find -lXcursor
I'll be searching whilst waiting for answers as to what provides the static libraries (via yum preferably), but any info would be nice.

However, am I going to run into problems or suchlike, and if so what can I do to sort them? e.g. Irrlicht could probably be built without support for various drivers and suchlike...?

Thankyou
 
Old 11-19-2015, 10:01 AM   #2
teapottwo
Member
 
Registered: Sep 2013
Posts: 52

Original Poster
Rep: Reputation: Disabled
I think I maybe ok with those libraries (not checked the gl version yet as VirtualBox has issues with mesa on my machine)


So, I'm only using:
Code:
-static-libgcc -static-libstdc++
 
Old 11-19-2015, 10:28 AM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Since you removed -static from your build command, you're no longer building a static executable. Run "ldd" on your executable to check.

It sounds like you're missing the static versions of those libraries (*.a versus *.so).
 
Old 11-19-2015, 12:18 PM   #4
teapottwo
Member
 
Registered: Sep 2013
Posts: 52

Original Poster
Rep: Reputation: Disabled
I'm on a Fedora 21 system, after compilation I transferred the compiled program to an instance of Kali (Debian) on VirtualBox and it ran fine. The Irrlicht library was already a static library.


From looking, I'll have to sort a lot of X11 to compile the needed static libraries and as Fedora say, it makes it vulnerable if bugs are found.

I'm no expert in this area though, far from it...


Running ldd showed a lot of shared libraries, mainly associated with X11 and one for GL.

Running nm showed a whole mass of lowercase types, so I'm guessing the Irrlicht library is in ok...? Not sure how else to analyse further...



So, how do other game developers compile statically, is it ok to build the above statically, won't it run into issues? If so I'll be happy to do a special source build, seems a big challenge which'd take me a day probably but if its worth it...?

cheers
 
Old 11-19-2015, 12:55 PM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Even with dynamic libraries it will run on other systems, provided their library versions are compatible with the one you used to build the executable.

A static executable will be more portable since it brings the libraries with it, but yes, if one of those libraries is found to have a bug, you'd need to rebuild and redistribute your executable with the patched library, rather than simply relying on the end user to patch their own library. This goes the other direction too though, if a bug is introduced into a library, your static executable would be immune to it, while a dynamic executable would start failing until the problematic library is patched.

If I need to distribute a program to multiple systems, I always either build it statically or distribute the source and build it locally on each system. Trying to distribute a pre-compiled dynamic executable can be very problematic, especially if you need to use it on a wide range of distros.
 
1 members found this post helpful.
Old 11-19-2015, 04:37 PM   #6
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,623

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
----
I'm on a Fedora 21 system,
----

BE Aware!!!

fedora 21 is at it's END OF LIFE!!!

there is and never will be any more support for it
no SECURITY updates on nothing
R.I.P. fedora 21 - you will be missed

upgrade to Fedora 23 ASAP
 
Old 11-19-2015, 05:42 PM   #7
teapottwo
Member
 
Registered: Sep 2013
Posts: 52

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by John VV View Post
----
I'm on a Fedora 21 system,
----

BE Aware!!!

fedora 21 is at it's END OF LIFE!!!

there is and never will be any more support for it
no SECURITY updates on nothing
R.I.P. fedora 21 - you will be missed

upgrade to Fedora 23 ASAP
TBH I dare not upgrade, things keep getting less usable and make me less productive, I still run a Fedora 18 machine for doing graphics. I use it as a workstation, not a tablet.
 
Old 11-19-2015, 05:50 PM   #8
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Sounds like you should switch distros to one that's a better match for your requirements. Fedora isn't for everyone.
 
Old 11-19-2015, 06:17 PM   #9
teapottwo
Member
 
Registered: Sep 2013
Posts: 52

Original Poster
Rep: Reputation: Disabled
Been using since Redhat 7, its more Gnome, GIMP, Files, etc, all config has changed, etc. Too much else to do than learn a new system every few months.

I know there are projects which use the old interfaces and config formats, but I haven't had the time recently to look into them, never mind test them out.
 
Old 11-19-2015, 08:27 PM   #10
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by teapottwo View Post
Too much else to do than learn a new system every few months.
Which is absolutely why you should not be using a distro like Fedora. Fedora is the polar opposite of what it sounds like you're looking for. Fedora is a VERY fast-paced bleeding-edge beta testing distro for Red Hat. You will always be inundated with new prototype program versions and config styles.

You would be much more at-home with RHEL/CentOS or Debian Stable from the sound of it.
 
Old 11-20-2015, 09:36 AM   #11
teapottwo
Member
 
Registered: Sep 2013
Posts: 52

Original Poster
Rep: Reputation: Disabled
lol, just dl'd ubuntu 14 LTS and installed default on VirtualBox, bleh, even worse, it feels like a kids toy...

CentOS, last time I used it didn't even have built-in support for mounting flash drives and such, way behind, either way it'll become Fedora sooner or later anyway.

Anyway, off-topic so I'll do another thread if required

Cheers
 
Old 11-21-2015, 06:58 AM   #12
genss
Member
 
Registered: Nov 2013
Posts: 741

Rep: Reputation: Disabled
to link against static libraries first make sure that they exists (the .la files instead of .so)
fedora is known to hate static linking, so do make sure

you can't statically link against libGL, though
as that library is provided by the specific opengl driver

the X11 things should be fine
then again X has a stable ABI (as far as your case goes) so there is no need to statically link it


the "security!" yells you can just ignore
you are building a game, not a TLS capable web server
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Thread limits in dynamic libraries as opposed to static libraries pmkenny1234 Linux - Software 0 04-26-2011 02:22 PM
static libraries eteck Programming 3 11-03-2010 08:39 AM
Static libraries vs shared Libraries catallergy Linux - Newbie 2 03-16-2010 01:30 PM
linking static libraries??? birjodh Linux - Newbie 3 06-13-2007 02:54 AM
Compiling with static libraries trek413 Linux - Newbie 4 10-19-2006 07:14 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration