|
Sorry stupid question I'm sure... |
StanEd
Member #16,038
August 2015
|
Hi guys, I've been away from allegro for a while; especially in Windows but I now need to setup a windows environment for a specific project. I followed the instructions here: https://wiki.allegro.cc/index.php?title=Windows,_Code::Blocks_and_Allegro_5 Which have been great; but I'm stuck on linking. I'd prefer static, but I really don't mind if dynamic is easier. I've tried this several ways: Attempt 1: Quote: When linking statically there are many more libraries that you need to link to. File:CBLinkerSettings2.png Here is the full list of libraries : -lallegro_monolith-debug-static So, I've made sure the allegro/lib folder is in the linker search directory and in codeblocks I do Project->Build Options->Linker settings then in the Other Linker options I paste the above. But on compilation it says it cannot find any of them. Addendum I have also added these to the Settings->Compiler linker settings. Trial 2: in the linked libraries section I have added 'liballegro-5.0.10-monolith-static-mt.a' which I understand to be enough to compile the following: 1#include <stdio.h>
2#include <stdlib.h>
3#include "allegro5/allegro.h"
4
5int main(int argc, char **argv){
6 ALLEGRO_DISPLAY *display = NULL;
7 if(!al_init()) {
8 fprintf(stderr, "failed to initialize allegro!\n");
9 return -1;
10 }
11 display = al_create_display(640, 480);
12 if(!display) {
13 fprintf(stderr, "failed to create display!\n");
14 return -1;
15 }
16 al_clear_to_color(al_map_rgb(0,0,0));
17 al_flip_display();
18 al_rest(10.0);
19 al_destroy_display(display);
20 return 0;
21}
But this gives undefined reference errors for all the allegro functions. I am guessing I am missing a linked library, but to be honest I can't work out which ones I would need to include. I guess that the assumption the the monolith is everything roled in to one is not correct? Can anyone point me to what I need to include or why the -l... options from the guidance wouldn't work? Thank you, Stan Further test I have now added a link to all the .a files that are labelled as static and the it still doesn't compiler (same reference errors). Thanks again, Stan |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Sorry, it looks like the wiki lost some files. I still have the originals and I'll re-upload them. Don't change your global compiler settings unless you really mean to. It's much better to use per-project settings. First, check that you set the correct linker directory : Then, if you're linking statically, you need to define ALLEGRO_STATICLINK in all files that include allegro. Honestly, linking dynamically is easier. It all depends on whether you want one file or many to distribute. If you link to the allegro monolith dynamically, then your executable will depend on all the dlls allegro needs. If you still have errors, please post them. 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 |
StanEd
Member #16,038
August 2015
|
Hi Edgar, Thanks, for replying and with the pictures. Edgar Reynaldo said: Don't change your global compiler settings unless you really mean to. It's much better to use per-project settings. Apologies I was unclear; I have set these on the project level; but while trying to get things working I also set them in the Global compiler settings. Mine are full pathed (c:\allegro\lib and c:\allegro\include) in both the project and global level. Edgar Reynaldo said: Honestly, linking dynamically is easier. It all depends on whether you want one file or many to distribute. If you link to the allegro monolith dynamically, then your executable will depend on all the dlls allegro needs. Ah, I thought Static was the preferred method, the aim is to make a few small tools for a larger project so I don't mind either way. Even setting the linkers as per the pictures (static or dynamic) I still get: ld.exe cannot find -lallegro_monolith-debug.dll
I'm a bit vague on how the linker name relates to the actual filename. For example, I have these files:
I did open these in notepad++ and had a look through but I couldn't identify a library name? Does the filename relate to the linker name? (I took the mingw 4.7 binaries from https://www.allegro.cc/files/) so it's allegro 5.0.10, but I'm not sure if I need a different linker name? Thanks again, Stan |
Edgar Reynaldo
Major Reynaldo
May 2007
|
If you have a library called libNAME.a, you link to it with -lNAME It all depends on where you got your binaries from and what your library files are actually named. To set a linker search directory you pass -L DIR EDIT https://wiki.allegro.cc/index.php?title=Windows,_Code::Blocks_and_Allegro_5 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 |
StanEd
Member #16,038
August 2015
|
Hi Edgar, Thanks for updating the images . I did think it was related to the filenames; so it's odd that mine is still saying it can't find them. I wonder if I've messed something else up in setup, so I think over the weekend I will start again from scratch and see if I can get better results. Thank you for your help and patience. Stan |
Edgar Reynaldo
Major Reynaldo
May 2007
|
If you still can't get it to work, post a zip of your source and project files and I will see if I can tell what's wrong. 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 |
StanEd
Member #16,038
August 2015
|
Hi Edgar, Just thought I'd let you know that I started from scratch again today, and this time found the latest binaries at: https://github.com/liballeg/allegro5/releases rather than with the 5.0.* binaries here: https://www.allegro.cc/files/; and I managed to get it working fine. No idea what was wrong in my previous attempt but got it working so I'm happy with that . Thank you ever so much for your help. Btw, I went with Dynamic in the end Stan |
|