|
Linking to Allegro 4.4.2 |
Christer Sandberg
Member #16,831
March 2018
|
I want to build an application that depends on Allegro 4.4.2. This works fine on Linux. On Windows I followed the instructions for MinGW32 and Cmake, and Allegro built and installed fine (using the default options to CMake). I have verified that liballeg.a is present in MinGW\lib and allegro.h as well as the directory allegro is present in MinGW\include. and then get: c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../liballeg.a(wsystem.c.obj): In fun ction `sys_directx_get_desktop_resolution': C:/allegro/allegro-4.4.2/allegro/src/win/wsystem.c:434: undefined reference to ` GetDeviceCaps@8' C:/allegro/allegro-4.4.2/allegro/src/win/wsystem.c:435: undefined reference to ` GetDeviceCaps@8'
(more undefined refs follows) |
Peter Hull
Member #1,136
March 2001
|
Try adding -lgdi32 to the compiler command line
|
Christer Sandberg
Member #16,831
March 2018
|
That made difference, but there are still lots of unsolved references. C:/allegro/allegro-4.4.2/allegro/src/win/wkeybd.c:679: undefined reference to `I ID_IDirectInputA' C:/allegro/allegro-4.4.2/allegro/src/win/wkeybd.c:679: undefined reference to `C LSID_DirectInput' C:/allegro/allegro-4.4.2/allegro/src/win/wkeybd.c:679: undefined reference to `C oCreateInstance@20'
etc. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You're linking to the static library, which means you also need to link to all the dependencies. I think this is the full list of libraries you need to link to besides liballeg.a : -static -lalleggl -ljpgalleg -lloadpng -llogg -lalleg-debug-static -lvorbis -lvorbisenc -lvorbisfile -logg -lpng16 -lzlibstatic -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lole32 -ldinput -lddraw -ldxguid -lwinmm -ldsound -static-libstdc++ -static-libgcc 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 |
Christer Sandberg
Member #16,831
March 2018
|
What makes you believe that I'm linking statically? There is no library liballeg-static.a only liballeg.a, so at least according to the docs it has been built dynamic. That is also what should happen if using default settings to CMake, again according to docs. On the other hand liballeg.a is surprisingly big (4.5M) to be for dynamic linking. So maybe you are right. I tested to compile again but without -lloadpng -llogg -lalleg-debug-static -lvorbis -lvorbisenc -lvorbisfile -logg -lpng16 -lzlibstatic -lstatic-libstdc++
since they are not present on my system, and it worked. Now I also tried to build a copy of extrans.c using the same options to gcc as above which did not work: |
Edgar Reynaldo
Major Reynaldo
May 2007
|
liballeg.a is the static version of Allegro 4.4. liballeg44.dll.a is the dynamic version. When linking statically, you need to pass -DALLEGRO_STATICLINK to your compile options. That's where the _imp* stuff is coming from. 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 |
Christer Sandberg
Member #16,831
March 2018
|
OK, thanks! (didn't test -DALLEGRO_STATICLINK before because I still trusted the docs' statement about library naming). |
Edgar Reynaldo
Major Reynaldo
May 2007
|
ryafar said: Is there a way to tell CMake to generate makefiles to force make to show the actual commands that are issued instead of the message that it was successful? You can set the CMAKE_VERBOSE_MAKEFILE option to 'On', and it will give you much more information. Probably too much. 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 |
|