|
Static compiling MinGW |
Ponkutsu
Member #16,562
September 2016
|
Hello! I have been trying to compile an Allegro program using the static library in MinGW. I failed to do it manually in the command line so I tried with Code::Blocks using this guide: https://wiki.allegro.cc/index.php?title=Windows,_Code::Blocks_and_Allegro_5. Some questions: 1) Are you supposed to just copy the "lib" and "include" directories to MinGW's corresponding directories? How can you update Allegro if you just mix in files like that? 2) Are you supposed to pick x86 or x64 depending on the platform you compile on or is it that you pick what the target platform is for your program? 3) So to avoid mixing the Allegro files with the MinGW files I went with the Code::Blocks guide. Here is what I did so far: *Installed MinGW with version 5.3.0 of gcc/g++. I get two undefined references to "__ms_vsnprintf" errors. Thanks for any help. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Ponkutsu said:
I have been trying to compile an Allegro program using the static library in MinGW. I failed to do it manually in the command line so I tried with Code::Blocks using this guide: https://wiki.allegro.cc/index.php?title=Windows,_Code::Blocks_and_Allegro_5. That guide is pretty outdated.... Ponkutsu said: 1) Are you supposed to just copy the "lib" and "include" directories to MinGW's corresponding directories? How can you update Allegro if you just mix in files like that? You can do it that way, but it's not a good way to do it, as you noted yourself. What you want to do is keep Allegro separate, and then set your compiler and linker search paths to include the "include" and "lib" folder of the allegro distribution respectively, using -I INCLUDE_DIR and -L LIB_DIR. Ex. mingw32-g++ -Wall -O0 -o game.exe -I c:\LIBS\Allegro5211_MinGW5302_Rel3\include -L c:\LIBS\Allegro5211_MinGW5302_Rel3\lib -lallegro_monolith-static -static -ldumb -lFLAC -lvorbisfile -lvorbis -lfreetype -logg -lpng16 -lzlibstatic -lgdiplus -luuid -lkernel32 -lwinmm -lpsapi -lopengl32 -lglu32 -luser32 -lcomdlg32 -lgdi32 -lshell32 -lole32 -ladvapi32 -lws2_32 -lshlwapi -static-libstdc++ -static-libgcc
Ponkutsu said: 2) Are you supposed to pick x86 or x64 depending on the platform you compile on or is it that you pick what the target platform is for your program? x86 is for 32 bit and x64 is for 64 bit. It depends on your compiler. MinGW by itself is only for x86. Ponkutsu said: 3) So to avoid mixing the Allegro files with the MinGW files I went with the Code::Blocks guide. Here is what I did so far: *Installed MinGW with version 5.3.0 of gcc/g++. I get two undefined references to "__ms_vsnprintf" errors.
Installing MinGW 5.3.0 is correct. I provide binaries for the stand alone MinGW 5.3.0-2 that include all the dependencies with it. These should work for you. Download the latest version from here : 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 |
Ponkutsu
Member #16,562
September 2016
|
Edgar Reynaldo said: Ponkutsu said: I have been trying to compile an Allegro program using the static library in MinGW. I failed to do it manually in the command line so I tried with Code::Blocks using this guide: https://wiki.allegro.cc/index.php?title=Windows,_Code::Blocks_and_Allegro_5. That guide is pretty outdated.... 1) Are you supposed to just copy the "lib" and "include" directories to MinGW's corresponding directories? How can you update Allegro if you just mix in files like that? You can do it that way, but it's not a good way to do it, as you noted yourself. What you want to do is keep Allegro separate, and then set your compiler and linker search paths to include the "include" and "lib" folder of the allegro distribution respectively, using -I INCLUDE_DIR and -L LIB_DIR. Ex. mingw32-g++ -Wall -O0 -o game.exe -I c:\LIBS\Allegro5211_MinGW5302_Rel3\include -L c:\LIBS\Allegro5211_MinGW5302_Rel3\lib -lallegro_monolith-static -static -ldumb -lFLAC -lvorbisfile -lvorbis -lfreetype -logg -lpng16 -lzlibstatic -lgdiplus -luuid -lkernel32 -lwinmm -lpsapi -lopengl32 -lglu32 -luser32 -lcomdlg32 -lgdi32 -lshell32 -lole32 -ladvapi32 -lws2_32 -lshlwapi -static-libstdc++ -static-libgcc Thanks, this works! I wonder why some guides insist on copying the library to the MinGW directories though. Edgar Reynaldo said: Ponkutsu said: 2) Are you supposed to pick x86 or x64 depending on the platform you compile on or is it that you pick what the target platform is for your program? x86 is for 32 bit and x64 is for 64 bit. It depends on your compiler. MinGW by itself is only for x86. I see, official MinGW is only for 32-bit. I don't think I will make 64-bit programs anyway. And 32-bit is better for compatibility. Edgar Reynaldo said: Ponkutsu said: 3) So to avoid mixing the Allegro files with the MinGW files I went with the Code::Blocks guide. Here is what I did so far: *Installed MinGW with version 5.3.0 of gcc/g++. I get two undefined references to "__ms_vsnprintf" errors. Installing MinGW 5.3.0 is correct. I provide binaries for the stand alone MinGW 5.3.0-2 that include all the dependencies with it. These should work for you. Download the latest version from here :
Thanks a lot! This helped, now I can compile in the command line as well as Code::Blocks. |
Audric
Member #907
January 2001
|
Ponkutsu said: Thanks, this works! I wonder why some guides insist on copying the library to the MinGW directories though.
These are standard locations, so every makefile written with the assumption that the library is in default location will work. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
And if you try to compile allegro with allegro already installed? Well, have fun. 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 |
Ponkutsu
Member #16,562
September 2016
|
I see, it really is troublesome to compile someone else's code like this. Still Allegro binaries doesn't come with an installer or anything so it's a pain to uninstall manually if you need to try another build. You might as well keep a batch file for compiling Allegro projects. Or a project template in an IDE that links everything. But if a project relies on a complicated makefile it might not work so well I guess. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Most projects worth their salt that use allegro will allow you to specify an install directory where allegro is located. If they don't, they're not all that useful. It's as simple as setting a few search directories in a codeblocks project, or setting an environment variable in cmake. 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 |
|