![]() |
|
Allegro 4.4.2 - AllegroGL addon static only? |
OICW
Member #4,069
November 2003
![]() |
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
[My website][CppReference][Pixelate][Allegators worldwide][Who's online] |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
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. 910if(WANT_FRAMEWORKS)
911 set(ADDON_LINKAGE SHARED)
912else()
913 set(ADDON_LINKAGE STATIC)
914endif()
Replace that with this : 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. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
OICW
Member #4,069
November 2003
![]() |
Thanks a lot. That did the trick, as a sideeffect I was able to build Openlayer in a way that it actually renders fonts 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] |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
There should be a line in CMakeLists.txt that has the command 'target_link_libraries'. Find the one for the static openlayer example programs, and then add in all the static libraries there. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
OICW
Member #4,069
November 2003
![]() |
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] |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
No need to fear. Here's the list of static libraries you need to link to for mingw with allegro 4.4 : 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. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
OICW
Member #4,069
November 2003
![]() |
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] |
|