[OLD-1] AGS engine Linux port

Started by BigMc, Sun 03/06/2012 19:04:20

Previous topic - Next topic

JJS

#120
Try removing "-pie -fpie" from the CFLAGS for that last error.

Afaik (not) setting -DALLEGRO_STATICLINK does not make any difference for the non-Windows builds. All mobile versions get static linked with all support libraries so it is possible to static link. Exception is libc for Android and I don't really know how iOS does this as it gets handled behind the scenes by xcode.

A thing with static linking Allegro is that the library has to be patched. It boils down to renaming pack_fopen() (see here: https://github.com/adventuregamestudio/ags/blob/master/Android/patches/liballegro-4.4.2.patch#L2526 ).
When dynamically linking the library is patched at run time. This patching also has to be disabled by removing -DAGS_RUNTIME_PATCH_ALLEGRO from the CFLAGS.
Ask me about AGS on PSP, Android and iOS! Source, Daily builds

scottchiefbaker

If I change the makefile to remove -pie, -fpie and add -static:

CFLAGS = -O2 -g -static -fsigned-char -Wfatal-errors -DNDEBUG -DAGS_HAS_CD_AUDIO -DAGS_CASE_SENSITIVE_FILESYSTEM -DALLEGRO_STATICLINK -DTHIS_IS_THE_ENGINE -DLINUX_VERSION -DDISABLE_MPEG_AUDIO -DBUILTIN_PLUGINS -DRTLD_NEXT $(shell pkg-config --cflags freetype2)

Everything compiles, but I get an error on linking:

Linking common library...
Linking engine...
/usr/bin/ld: cannot find -lalleg
/usr/bin/ld: cannot find -laldmb
/usr/bin/ld: cannot find -ldumb
collect2: error: ld returned 1 exit status
make: *** [ags] Error 1

JJS

I guess this would indicate that there are no static libraries for Allegro and DUMB present on the system?
Ask me about AGS on PSP, Android and iOS! Source, Daily builds

scottchiefbaker

Good question. Is that something that needs to be built ahead of time? I just assumed they would be built on the fly when we compile ags statically.

JJS

Quote from: scottchiefbaker on Sun 27/01/2013 18:37:31Is that something that needs to be built ahead of time? I just assumed they would be built on the fly when we compile ags statically.
Yes, definitely. You have to get the sources for Allegro 4.4.x and DUMB (0.9.3 I think, the newest one), patch Allegro (as described above) and then build them. Allegro goes first, then DUMB because it depends on it (aldumb). You also have to ensure that DUMB uses the newly built static libraries instead of the system Allegro libraries. You can take a look at how the libraries are cross-compiled for Android: https://github.com/adventuregamestudio/ags/tree/master/Android/buildlibs/x86 This might help with where to get the libraries, the flags used and how to build them without installing them over the system libraries.
Ask me about AGS on PSP, Android and iOS! Source, Daily builds

scottchiefbaker

Wow I think that's a little beyond my ability. If Wadjet wants a simple way they can offer ags to Linux clients, are they going to have to build ags for each major distro? Is there another way to make a "universal binary?"

BigMc

When using the distributions Allegro, two binaries should be enough: one using Allegro 4.2 and one 4.4.

scottchiefbaker

Here is the binary/package that I came up with as a demo for Wadjet. It was compiled and works great on 64bit Fedora 17, using Allegro 4.4. Anyone have Ubuntu, Mint, Suse handy they could test this against?

http://www.perturb.org/tmp/shivah.tar.gz

Sslaxx

#128
[Never mind me, just being unusually dense for some reason!]
Stuart "Sslaxx" Moore.

scottchiefbaker

I do think we should try and strive for a cross-distro compatible binary. Once we have that, it will really open up the sale of adventure games on Linux/Steam/Humble Bundle. Maybe someone with more experience with the build system could build static binaries? I'd be happy to host them, if someone can build them.

FFMPEG offers static builds by community members:

http://ffmpeg.gusari.org/static/

scottchiefbaker

Quote from: BigMc on Sun 27/01/2013 23:39:20
When using the distributions Allegro, two binaries should be enough: one using Allegro 4.2 and one 4.4.

Wouldn't we need a 32bit and a 64bit one of each also?

BigMc

Quote from: scottchiefbaker on Mon 28/01/2013 18:44:42
Wouldn't we need a 32bit and a 64bit one of each also?

That is needed in any case.

The build from Fedora does not work on Debian, because libaldmb has a different soname here: libaldmb.so.1 instead of libaldmb-0.9.3.so

Another idea would be to use the openSUSE Build Service to provide AGS packages for all major distributions.

scottchiefbaker

Ubuntu does the same thing with libaldmb.so.1. I think perhaps it's a bug? No other distros do that, and it seems to be only for aldmb, as allegro is properly versioned and symlinked. Since the distros symlink properly:

lrwxrwxrwx 1 root root     15 Sep 14 09:09 liballeg.so -> liballeg.so.4.4
lrwxrwxrwx 1 root root     17 Sep 14 09:09 liballeg.so.4.4 -> liballeg.so.4.4.2
-rwxr-xr-x 1 root root 915840 Jan 12  2012 liballeg.so.4.4.2

Can we just link against liballeg.so and let the distro handle passing it off the specific version of the library. Or are we back to trying to figure out a static build?

Also, does AGS use any specific stuff from allegro 4.4, or would it work with 4.2 also?

BigMc

It's no bug. Upstream did not give libaldmb a soname, so the distributions had to make up their own ones. AGS also works with Allegro 4.2.

scottchiefbaker

Quote from: BigMc on Mon 28/01/2013 21:20:45
It's no bug. Upstream did not give libaldmb a soname, so the distributions had to make up their own ones. AGS also works with Allegro 4.2.

Ah ok... well that causes problems because we can't just link against /lib64/libaldmb.so.

If you're Wadjet and you want to release a Linux version of your game you want to sell on Steam and have it be cross distro (not have a diff executable for each distro combination) what's their best bet? Statically linked?

BigMc

Build AGS with

Code: AGS
make LDFLAGS="'-Wl,-rpath,\$\$ORIGIN/libs'"


and put the required shared libraries in the folder libs relative to the binary.

scottchiefbaker

That seems possible. We'll need someone whose capable of building the the libraries, and the binary. That's a little beyond my basic compiling skills.

BigMc

You can take the libraries from a distribution.

scottchiefbaker

Quote from: BigMc on Mon 28/01/2013 22:48:33
You can take the libraries from a distribution.

Oh! I was thinking they'd have to be the statically linked libraries. You're talking about just copying liballeg.so.4.2, etc to lib/ in the same dir?

BigMc

yes, copy liballeg.so.4.4.2 and the symlink liballeg.so.4.4, etc to libs/ in the same dir.

SMF spam blocked by CleanTalk