|
Undefined references for "al_show_native_message_box" |
nachos92
Member #15,959
May 2015
|
Hi everyone! This error is written after compiling the helloworld Allegro program in c++. What can I do??? |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You need to link to the libraries that you used in your program. You used the native dialog addon so you now have to link your program to it. How depends on the compiler you're using. 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 |
nachos92
Member #15,959
May 2015
|
How can I do that? Sorry for my ignorance |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Looks like you're on Linux if you're using pkg-config. The normal way to link a library is to use -lName, where Name is taken from libName.a. But you're using pkg-config and I'm not sure what the name for the dialog addon is in pkg-config. Someone who uses pkg-config should be able to help you more. 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 |
Chris Katko
Member #1,881
January 2002
|
Edgar Reynaldo said: Someone who uses pkg-config should be able to help you more. You can NOT use that piece of junk? All the tutorials I saw used it and it confused the heck out of me when I needed to add addons--nothing worked. I was so frustrated with Allegro 5 that when I finally got it working, I saved it to a bash script and have since copied that script around for every new project. This is it, it might not be perfectly correct, but it at least works on my installation: g++ main.cpp -o main -std=c++11 -g -I/usr/include/allegro5 -L/usr/lib /usr/local/lib/liballegro.so /usr/local/lib/liballegro_primitives.so /usr/local/lib/liballegro_image.so /usr/local/lib/liballegro_font.so -lglut -lGL -lGLU --openmp But you don't need the extra flags like openmp and c++11. nachos92: You could try adding the correct lib (whatever the native dialog lib .so file is) to that code. Something along the lines of liballegro_native.so. (Not sure, you can check your library directory). [edit] Come to think of it, those are all local lib directories. I don't think I ever got it to successfully install to root. -----sig: |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Chris Katko said:
Edgar Reynaldo said: Someone who uses pkg-config should be able to help you more. You can NOT use that piece of junk? All the tutorials I saw used it and it confused the heck out of me when I needed to add addons--nothing worked. Haha, no, you don't have to use it. Cut the `pkg-config --libs allegro_...` part out and run it in a terminal. You will see that all it does is output the actual linking commands. Somebody should really put up a quick pkg-config guide on the wiki for use with allegro. Personally I never liked using pkg-config. It actually takes more typing to use pkg-config than to use the actual linking commands, but it is useful for showing you the right commands to use when linking allegro when you know the correct aliases for the libraries. They're probably all named in a scheme similar to allegro_addon_name-5.X where in Nachos92's case it is probably allegro_native_dialog-5.0. No I take that back, I think it is just allegro_dialog-5.0. So the command would probably look like : g++ -Wall -O2 -o progname main.cpp `pkg-config --libs allegro-5.0 allegro_dialog-5.0` Personally in a similar case of use when there are a lot of libraries to link I just stuff all the link commands into an environment variable like %ALLEGRO_LIBS_STATIC% and then use that every time on the command line in the linking command. Same goes for pkg-config, you don't really want to type all that shit out over and over again do you? Especially when you just want to do a quick test and you can't remember all the libs you need. 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 |
Chris Katko
Member #1,881
January 2002
|
Edgar Reynaldo said: Same goes for pkg-config, you don't really want to type all that out over and over again do you? Yeah, that's why I always have a bash file called "go" that has all the compile information. -----sig: |
nachos92
Member #15,959
May 2015
|
Thanks for your help! I've tryed first with -I/usr/include/allegro5 but nothing.. then by adding "allegro_dialog-5.0" at the pkg-config line it worked! |
Polybios
Member #12,293
October 2010
|
target_link_libraries (<target> allegro allegro_font allegro_image ...) has always "just worked" for me when using CMake. |
|