Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Stand-alone executable (Linux)  (Read 3251 times)

Motsognirson

  • Escaped Lunatic
    • View Profile
Stand-alone executable (Linux)
« on: January 31, 2015, 07:09:13 pm »

This may reveal my ignorance of the dynamic library linking paradigm, but is it possible to compile a Dwarf Fortress binary for Linux that doesn't need any .so files?

I am trying to run Dwarf Fortress on a 64 bit machine that I don't have admin privileges on, so there are lots of multilib (?) shared object files that aren't installed.  I have been copying some over from my own 64 bit laptop and just dropping them into the libs/ directory.  To be specific, I am running Arch and I've been copying .so files from my own /usr/lib32/ directory.

This process seemed to get me closer to running the executable, but then I ran into a big wall because that machine didn't have a new enough glibc version (I assume I am missing some updated header files).

I figure if I could make an un-linked executable, I should be able to right it no problem.  Would such an executable be prohibitively large?

Thanks for any input.
Logged

wierd

  • Bay Watcher
  • I like to eat small children.
    • View Profile
Re: Stand-alone executable (Linux)
« Reply #1 on: February 04, 2015, 01:23:17 pm »

static linking is a thing, yes.

However, Toady owns the source, has said he will never release the source, and without that source  we  cant build a statically linked binary.

Most try to avoid static linking, because it includes all the bugs of the libraries, permanently, inside the executable.  when they are linked externally, updating the library can fix problems with the libaray's bugs without having to recompile the software using it. (usually).

Logged

lethosor

  • Bay Watcher
    • View Profile
Re: Stand-alone executable (Linux)
« Reply #2 on: February 04, 2015, 03:00:15 pm »

The OS X and Windows builds also distribute several libraries (although Linux is the only platform where libgraphics, DF's graphics code, is also a dynamically linked library).
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Kamamura

  • Bay Watcher
    • View Profile
Re: Stand-alone executable (Linux)
« Reply #3 on: February 04, 2015, 03:28:57 pm »

static linking is a thing, yes.

However, Toady owns the source, has said he will never release the source, and without that source  we  cant build a statically linked binary.

Most try to avoid static linking, because it includes all the bugs of the libraries, permanently, inside the executable.  when they are linked externally, updating the library can fix problems with the libaray's bugs without having to recompile the software using it. (usually).

That depends solely on how well the code in question is maintained. Libraries evolve constantly, some functions change behavior, some are deprecated, then removed completely. If a code is not maintained and uses dynamic libraries, one day it usually stops working. Static linking freezes the versions of the libraries in time, so the statically linked binary usually works the same way often years after the support was dropped. Also, for critical stuff like shell, it's often better to have a static library so that you won't deny yourself a remote access to a machine by a poorly planed upgrade.
Logged
The entire content consists of senseless murder, a pile of faceless naked women and zero regard for human life in general, all in the service of the protagonist's base impulses. It is clearly a cry for help from a neglected, self absorbed and disempowered juvenile badly in need of affectionate guidance. What a sad, sad display.

Motsognirson

  • Escaped Lunatic
    • View Profile
Re: Stand-alone executable (Linux)
« Reply #4 on: February 10, 2015, 07:25:59 pm »

Thank you for the replies!

However, Toady owns the source, has said he will never release the source, and without that source  we  cant build a statically linked binary.

This seems to be quite a hack, in fact the author admits as much, but this program does seem to attempt to take dynamically linked binary + .so files and create one (giant) bundled static executable, no?

http://statifier.sourceforge.net/

I tried this and got an error because (as far as I could tell), the program didn't want to create a 32bit binary on my 64bit laptop.
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: Stand-alone executable (Linux)
« Reply #5 on: February 11, 2015, 03:08:49 pm »

Wait, it won't run from inside of your home folder, or did you mean you can't get stuff installed under your /usr section?
Logged

Shashu

  • Bay Watcher
    • View Profile
Re: Stand-alone executable (Linux)
« Reply #6 on: February 11, 2015, 05:04:51 pm »

Personally I just download the Windows version and run it in Wine. I find it runs at least as well, or better.
Logged

Motsognirson

  • Escaped Lunatic
    • View Profile
Re: Stand-alone executable (Linux)
« Reply #7 on: February 11, 2015, 08:59:18 pm »

Wait, it won't run from inside of your home folder, or did you mean you can't get stuff installed under your /usr section?

It won't run from inside my home folder (missing libraries) and I can't get anything installed into /usr.  I also don't have privileges to use a package manager.  I am essentially wondering if, in this age of dynamically linked libraries, it is possible to have a stand alone version of Dwarf Fortress run from one's own $HOME.
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: Stand-alone executable (Linux)
« Reply #8 on: February 12, 2015, 01:05:23 am »

Down that way lies all sorts of screwed up file trees.

I suppose you could try something like putting a /usr folder inside /home with the library in there and symlink to it, I used to know stuff for doing that off the top of my head, but oddly enough after switching to arch I haven't needed to do it since. It's generally not the best idea though, where is the person with the admin privileges?
Logged

draeath

  • Bay Watcher
  • So it has come to this...
    • View Profile
Re: Stand-alone executable (Linux)
« Reply #9 on: February 12, 2015, 01:02:33 pm »

Note you can put the libraries anywhere you want and set the variable LD_LIBRARY_PATH to include the normal paths plus your new paths.

This will make the linker search your custom directories for .so files, so you can use your own local libs :)

EG:
Code: [Select]
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/whoever/lib
./dwarf-fortress-super-happy-funtime-go
« Last Edit: February 12, 2015, 01:05:46 pm by draeath »
Logged
Urist McAlchemist cancels extract isotope: interrupted by supercriticality accident.
This kea is so raw it stole my wheelbarrow!

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: Stand-alone executable (Linux)
« Reply #10 on: February 12, 2015, 07:20:46 pm »

THAT'S WHAT IT WAS, thanks on their behalf! I was trying to remember how I did that before to fix df before I moved to arch which happily has really good df support.
Logged

Motsognirson

  • Escaped Lunatic
    • View Profile
Re: Stand-alone executable (Linux)
« Reply #11 on: February 12, 2015, 09:27:21 pm »

where is the person with the admin privileges?

So you sniffed me out.  I was trying to use the nice computers at my work to run df, at least for world gen ;)

I did get a (long history) world generated eventually, so for now my interest in this question is purely academic.
Logged