Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Allegro 4.4.2 - AllegroGL addon static only?

Credits go to Edgar Reynaldo for helping out!
This thread is locked; no one can reply to it. rss feed Print
Allegro 4.4.2 - AllegroGL addon static only?
OICW
Member #4,069
November 2003
avatar

Hi there, this is a kind of a follow up on my previous question. I've tried to build all my old and abandoned projects and some of them are using AllegroGL and some of them are using OpenLayer. It took me quite a while before I realised that cmake build of Allegro 4.4.2 builds AllegroGL as static only so I had to pepper all my `pkg-config --libs allegrogl allegro` in makefiles with --static.

The problem arose when I tried to build OpenLayer 2.1[1] - I had to skip building of the demos because this line in their respective CMakeLists.txt causes the build to fail:

target_link_libraries(gamedemo openlayer ${ALLEGROGL_LIBRARY} ${PNG_LIB} ${GLYPHKEEPER_LIB} ${FREETYPE_LIB} ${ZLIB_LIB} ${ALLEGRO_LIBRARY} ${OPENGL_LIBRARIES} ${WIN_LIBS})

with this output:

Linking CXX executable ../bin/collisiondemo
/usr/bin/ld: /usr/local/lib/liballeggl.a(x.c.o): undefined reference to symbol 'XcursorImageDestroy'
/usr/lib/x86_64-linux-gnu/libXcursor.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [bin/collisiondemo] Error 1
make[1]: *** [demos/CMakeFiles/collisiondemo.dir/all] Error 2
make: *** [all] Error 2

So my question is: why is the AllegroGL addon built as static only? Why not as an .so/.dll anymore?

Bonus question #1: how do I modify the CMakeLists.txt to accommodate for static linking?

Bonus question #2: where do I send patch for OpenLayer to actually build on Linux using gcc 4.8.2?

References

  1. It took me quite a while before I found the linked archive - the only one among many versions I've tried that's capable of building using cmake. Though, I had to make some changes.

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

The cmake variable that determines whether the addons get created statically or dynamically is $(ADDON_LINKAGE). It is only set on lines 910-914 of CMakeLists.txt.

The global variable that determines library linkage is $(BUILD_SHARED_LIBS), and is set based on the value of the cmake variable $(SHARED).

If we set $(ADDON_LINKAGE) to $(BUILD_SHARED_LIBS) it should work then if you use -DSHARED=On. Currently it sets ADDON_LINKAGE based on WANT_FRAMEWORKS.

allegro442/CMakeLists.txt#SelectExpand
910if(WANT_FRAMEWORKS) 911 set(ADDON_LINKAGE SHARED) 912else() 913 set(ADDON_LINKAGE STATIC) 914endif()

Replace that with this :

allegro442/CMakeLists.txt#SelectExpand
910if (BUILD_SHARED_LIBS) 911 set(ADDON_LINKAGE SHARED) 912else() 913 set(ADDON_LINKAGE STATIC) 914endif() 915 916if(WANT_FRAMEWORKS) 917 set(ADDON_LINKAGE SHARED) 918endif()

and then delete CMakeCache.txt and rerun cmake. That should get you your dynamic build of allegrogl. I tested it on Vista with MinGW and the dlls are built so it should work on *nix too.

I'll submit a proper patch after I get Allegro 4.4.X cloned from git.

OICW
Member #4,069
November 2003
avatar

Thanks a lot. That did the trick, as a sideeffect I was able to build Openlayer in a way that it actually renders fonts :) (which I cannot say about several of my projects using pure AllegroGL or Allegro 5, but for this I blame my mobile ATI HD3430 and funny OSS drivers).

Anyway, any idea how to tell cmake to include dependencies when statically linking some library? Or do I need to keep track of those myself across various platforms?

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

OICW
Member #4,069
November 2003
avatar

Yeah, I was afraid that you'll say that. The reason I was asking was that in an unlikely possibility of porting some of my programs to Windows using cmake the need for static linking might arise and in that case I guess I would have to first check for platform because Allegro, for example, depends on different librarires depending on the target platform.

Anyway, thanks again for the help.

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

No need to fear.

Here's the list of static libraries you need to link to for mingw with allegro 4.4 :
-lkernel32 -luser32 -lgdi32 -lcomdlg32 -lole32 -ldinput -lddraw -ldxguid -lwinmm -ldsound

I'm sure with some googling or proper exploration of allegro you can find the rest for *nix and osx.

CMake makes it easy to detect the platform as far as I can tell - all you need is to check a few global cmake variables.

OICW
Member #4,069
November 2003
avatar

Now I realise that I've attributed some magical powers into the Cmake. Anyway, thanks again. I should bookmark this thread for future reference.

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

Go to: