LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Static Libraries (https://www.linuxquestions.org/questions/programming-9/static-libraries-4175559306/)

teapottwo 11-19-2015 09:21 AM

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

teapottwo 11-19-2015 10:01 AM

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++

suicidaleggroll 11-19-2015 10:28 AM

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).

teapottwo 11-19-2015 12:18 PM

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

suicidaleggroll 11-19-2015 12:55 PM

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.

John VV 11-19-2015 04:37 PM

----
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

teapottwo 11-19-2015 05:42 PM

Quote:

Originally Posted by John VV (Post 5452294)
----
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.

suicidaleggroll 11-19-2015 05:50 PM

Sounds like you should switch distros to one that's a better match for your requirements. Fedora isn't for everyone.

teapottwo 11-19-2015 06:17 PM

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.

suicidaleggroll 11-19-2015 08:27 PM

Quote:

Originally Posted by teapottwo (Post 5452346)
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.

teapottwo 11-20-2015 09:36 AM

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

genss 11-21-2015 06:58 AM

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


All times are GMT -5. The time now is 06:16 AM.