Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Linking Libraries for Dummies

Credits go to Matthew Leverton and MiquelFire for helping out!
This thread is locked; no one can reply to it. rss feed Print
Linking Libraries for Dummies
Aaron Whipple
Member #4,001
November 2003
avatar

I'm a coder with a significant amount of experience, however the one area that I literally know nothing about is linking libraries. I have been trying to set allegro up in Code Blocks and mingw and I am drawing blanks. Ive been searching for guides and many of them say I need to build allegro. Is that really necessary? I would think there was a pre-compiled version to use. Another site said that I needed subversion at which point I quickly clicked my back button, as I cant see how source control has anything to do with it...

To get to the point, I don't want a step by step guide to setting up Allegro. What I really need is a good resource to start learning about linking libraries in general so I can do it myself in the future without having to ask for help. Any recommendations are greatly appreciated. Thanks in advance!

P.S. Is Allegro 5 stable? I couldn't find information on whether I should start with 5 or just stick with 4 right now.

gnolam
Member #2,030
March 2002
avatar

What I really need is a good resource to start learning about linking libraries in general so I can do it myself in the future without having to ask for help.

There isn't mich to say on that topic other than "link with the library in question and its dependencies, with whatever extra linker flags are needed". :P
(How to find those dependencies and linker flags depends on the library)

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Aaron Whipple
Member #4,001
November 2003
avatar

I suppose the trouble I have is locating good documentation for individual libraries then. The version of Allegro 5 I downloaded had no documentation...

MiquelFire
Member #3,110
January 2003
avatar

I don't know about the MinGW version, but on MSVC, you just add the normal Allegro libraries you need (if you're using the DLL version) and just accept the default libs MSVC puts in anyway.

I don't know what the extra libs for static linking are however. But I do know you need to define ALLEGRO_STATICLINK (or something like that) in your project.

---
Febreze (and other air fresheners actually) is just below perfumes/colognes, and that's just below dead skunks in terms of smells that offend my nose.
MiquelFire.red
If anyone is of the opinion that there is no systemic racism in America, they're either blind, stupid, or racist too. ~Edgar Reynaldo

Matthew Leverton
Supreme Loser
January 1999
avatar

P.S. Is Allegro 5 stable? I couldn't find information on whether I should start with 5 or just stick with 4 right now.

Use version 5 RC2.

The files page here will have appropriate build / setup documentation by the time version 5.0.0 is out. Until then you'll need to look up the wiki for info or read the installation instructions that come with the source.

The API manual is online.

Aaron Whipple
Member #4,001
November 2003
avatar

Thanks for all the help everyone. I managed to get version 4 working. Now I just need to find a pre-built version of 5. I think I am beginning to understand this whole linking thing a bit now ;D

Thomas Fjellstrom
Member #476
June 2000
avatar

Now I just need to find a pre-built version of 5

http://www.allegro5.org has A5 binaries.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Matthew Leverton
Supreme Loser
January 1999
avatar

Now I just need to find a pre-built version of 5.

http://www.allegro.cc/files has A5 binaries.

But maybe you should check under your bed first. :-X

Aaron Whipple
Member #4,001
November 2003
avatar

Surprise! I'm back again. I successfully got Allegro 4 working. I am now trying to set up allegro 5 though and have run into a problem. I downloaded Allegro 5.0.0 for Mingw 4.4.0. I linked in the same way as allegro 4 was linked (lib and include folders) and used liballegro_main-5.0.0-RC2-md.a It seems to recognize the include file alright, but once I compile the following code, I get errors. Ive already spent the last couple hours searching around for any indication of what I may have done wrong.

[code]
#include <stdio.h>
#include <allegro5/allegro.h>

int main(int argc, char **argv)
{
ALLEGRO_DISPLAY *display = NULL;

if(!al_init()) {
fprintf(stderr, "failed to initialize allegro!\n");
return -1;
}

display = al_create_display(640, 480);
if(!display) {
fprintf(stderr, "failed to create display!\n");
return -1;
}

al_clear_to_color(al_map_rgb(0,0,0));

al_flip_display();

al_rest(10.0);

al_destroy_display(display);

return 0;
}
[/code]

obj\Release\main.o:main.cpp|| undefined reference to `al_install_system'|
obj\Release\main.o:main.cpp|| undefined reference to `al_create_display'|
obj\Release\main.o:main.cpp|| undefined reference to `al_map_rgb'|
obj\Release\main.o:main.cpp|| undefined reference to `al_clear_to_color'|
obj\Release\main.o:main.cpp|| undefined reference to `al_flip_display'|
obj\Release\main.o:main.cpp|| undefined reference to `al_rest'|
obj\Release\main.o:main.cpp|| undefined reference to `al_destroy_display'|
||=== Build finished: 7 errors, 0 warnings ===|

I also attempted to compile a much simpler program, only calling al_init to minimize potential problems. Same issue though.

Matthew Leverton
Supreme Loser
January 1999
avatar

You need to link against liballegro-5.0.0-RC2-md.a as well.

Aaron Whipple
Member #4,001
November 2003
avatar

After adding that I ended up getting an error saying that libgcc_s_dw2-1.dll was missing from my system. I suppose its a dependency of allegro 5. Anyways, I just downloaded the dll from a 3rd party site and copied it to my mingw folder. Allegro 5 seems to be working now.

Thanks again for all the help.

By the way, how do you link code on the forums? I thought the old tag was [code][/code] but i guess thats wrong :o

SpectreNectar
Member #10,969
May 2009
avatar

Good for you that you have it working ^^

Just wanted to share the formatting help button that you see just above the text field. It's right next to preview. Code is done like this:

< code start="1">int x = 1;< /code>

int x = 1;

(Without spaces at the beginning)

Thomas Fjellstrom
Member #476
June 2000
avatar

I suppose its a dependency of allegro 5.

Nope. Its a dependency of GCC itself. You can skip that by adding -static-libgcc to your linking options.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Aaron Whipple
Member #4,001
November 2003
avatar

ah, Thank you. I was trying to locate that button ;D

Trent Gamblin
Member #261
April 2000
avatar

Offtopic, but this is the first I've seen this site having A5 binaries. I'm going to lay allegro5.org to rest now. I'll make a backup for what it's worth and alias it to http://alleg.sf.net.

LennyLen
Member #5,313
December 2004
avatar

Just wanted to share the formatting help button that you see just above the text field. It's right next to preview. Code is done like this:

< code start="1">int x = 1;< /code>

You can escape the XHTML tags with a '\' if you want to show someone what tags are required without them being parsed.

e.g. \<code start="1">int x = 1;</code> will display <code start="1">int x = 1;</code>

Go to: