Statically Linked Linux Binary?

Discussion of all aspects of the game engine, including development of new and existing features.

Moderator: Forum Moderators

Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Statically Linked Linux Binary?

Post by Dave »

We definitely don't have the resources to provide a Wesnoth binary for every distribution of Linux.

However, how difficult would it be to make a statically linked binary for Linux, that would be runnable on almost any distribution?

I have no idea how to do this kind of thing. Does anyone?

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
Icekiss
Posts: 63
Joined: February 19th, 2004, 11:50 am

Post by Icekiss »

Thats not hard. From the gcc man-page:
-static
On systems that support dynamic linking, this prevents linking with the shared libraries. On other systems, this option has no effect.

All you have to do, is change the gcc Flag variables in the Makefiles and add "-static" to them. I have done so, and compiling Weshnot that way right now. Looks like every sourcefile is compiled using this Flag and there are no errors. Of course I don't have the means to test out whether the result really works without the libraries: I'm not going to install an older version of libc :wink:
But if you want to, I can either send you the compiled result (better: upload it somewhere) or I could send you the modified Makefiles. Of course they won't work for you if you have a different version of Linux running (I have Debian unstable), and ./configure would overwrite the Makefiles...
However, changing them yourself really isn't all that hard.
Guest

Post by Guest »

Mhhh...
Doesn't seem to work fully automatic :(
The code compiled Ok, but did not link

The message I got:
martin@Terminus:~/downloads/wesnoth-0.7$ make
make all-recursive
make[1]: Entering directory `/home/martin/downloads/wesnoth-0.7'
Making all in src
make[2]: Entering directory `/home/martin/downloads/wesnoth-0.7/src'
Making all in .
make[3]: Entering directory `/home/martin/downloads/wesnoth-0.7/src'
g++ -I/usr/include/SDL -D_REENTRANT -DWESNOTH_PATH=\"/usr/local/share/wesnoth\" -g -O2 -static -lSDL -lpthread -lSDL_image -lSDL_mixer -lSDL_net -lSDL_ttf -o wesnoth about.o actions.o ai.o ai_attack.o ai_move.o config.o dialogs.o display.o events.o filesystem.o font.o game.o game_config.o game_events.o gamestatus.o hotkeys.o image.o intro.o key.o language.o log.o map.o mapgen.o mapgen_dialog.o mouse.o multiplayer.o multiplayer_client.o multiplayer_connect.o multiplayer_lobby.o network.o pathfind.o playlevel.o playturn.o preferences.o race.o replay.o reports.o sdl_utils.o show_dialog.o sound.o team.o terrain.o theme.o tooltips.o unit.o unit_types.o video.o button.o combo.o menu.o scrollbar.o slider.o textbox.o widget.o
about.o(.text+0x1c29): In function `about::show_about(display&)':
/home/martin/downloads/wesnoth-0.7/src/scoped_resource.hpp:88: undefined reference to `SDL_UpperBlit'
about.o(.text+0x1de2):/home/martin/downloads/wesnoth-0.7/src/scoped_resource.hpp:88: undefined reference to `SDL_UpperBlit'

I verified that the code DOES compile for me without the static option.
It looks like it can't find its files it needs. I checked though: The searched directory is there. I tried inserting a space behind the "-l", but that does not change the result. I don't now how to proceed from here...

Dave, or anybody else?
Icekiss
Posts: 63
Joined: February 19th, 2004, 11:50 am

Post by Icekiss »

Sorry, that was me...
Small addition: The error above was followed by a bootload of other SDL references that weren't found (didn't look informative to me, just repeticion of the same problem. If sb. wants them, let me now)
Woodwizzle
Posts: 719
Joined: December 9th, 2003, 9:31 pm
Contact:

Post by Woodwizzle »

I don't know much at all about cross-distro linux binaries, but I do know that ADOM (a great, but closed source game) is available in ELF format and runs on every distro I've tried it on. I don't know what ELF is though but I hope it helps :)
Guest

Post by Guest »

ELF simply is the standard executable file format in Linux (and other Unixes)
The a.out file gcc spits out is in this format...
Icekiss
Posts: 63
Joined: February 19th, 2004, 11:50 am

Post by Icekiss »

me...
(this damn site won't remember me, and I forget to log in time and again *sigh*)
ziberpunk

Post by ziberpunk »

I've built a static binary with current CVS codebase. You can get it here. Please test it.

To run it you have to do:

Code: Select all

./wesnoth path/to/data/files
If you test it, please tell us which version of glibc you have and if it worked or not.
miyo
Posts: 2201
Joined: August 19th, 2003, 4:28 pm
Location: Finland

Post by miyo »

Works fine for me:

Debian GNU/Linux (Sid), libc6: 2.3.2.ds1-11

- Miyo
cp1134
Posts: 1
Joined: June 24th, 2004, 11:16 pm
Location: Chula VIsta, CA

Static binary

Post by cp1134 »

The static binary works fine for me with:
  • Slackware 9.0

    Glibc 2.3.1
P.S. I'm new here and just wanted to say that this is a fun game. :D

-Chris Potter
"Mind over matter: If you don't mind, then it doesn't matter."
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Re: Static binary

Post by Dave »

cp1134 wrote: P.S. I'm new here and just wanted to say that this is a fun game. :D
Thanks; glad you enjoy it! :)

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
TuxVader
Posts: 114
Joined: April 14th, 2004, 7:34 am

Post by TuxVader »

YESSS!!! I couldn't get the new versions (.7.8+) working on linux, because I need a new version of gcc to compile them, but this could really help me! :D
It runs on SuSE 8.1 (linux kernel 2.4.x, glibc 2.2). Of course it doesn't run THAT well because I'm using the .7.7 data files! :oops:
Dark penguin of the sith.
TuxVader
Posts: 114
Joined: April 14th, 2004, 7:34 am

Post by TuxVader »

Is anybody going to mack a static binary for the latest release? :D
I NEED it!! :cry:
Dark penguin of the sith.
ziberpunk

Post by ziberpunk »

TuxVader wrote:Is anybody going to mack a static binary for the latest release? :D
I NEED it!! :cry:
Static binaries for 0.7.11 and 0.8 have been done and will be available as soon as possible.
TuxVader
Posts: 114
Joined: April 14th, 2004, 7:34 am

Post by TuxVader »

Great!! Hopefully this will help all the people that have problems compiling from source! Could they be packaged with the datafiles and given an install script?
Dark penguin of the sith.
Post Reply