Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Installing allegro 5 on MVSC 2010

This thread is locked; no one can reply to it. rss feed Print
Installing allegro 5 on MVSC 2010
Inquisiteur
Member #12,428
December 2010

Hi all,

I have beginner/intermediate knowledge in coding using Dev-C++. I thought this compiler was very user friendly, however now I am willing to move to something more "standard" and I installed Microsoft Visual C++ 2010.

Most of my knowledge was coding using the Ncruses library, quite ugly interface but very straightforward for displaying stats in console mode.

Anyway, I have installed MVSC 2010, downloaded allegro 5, copy pasted all files where they should go.

However, when I take any example such as the one displayed here:
http://wiki.allegro.cc/index.php?title=Allegro_5_Tutorial/Displays

when I hit the compile button I have the following errors:

1>------ Build started: Project: Allegro_testrun, Configuration: Debug Win32 ------
1> Main.cpp
1>Main.obj : error LNK2019: unresolved external symbol __imp__al_destroy_display referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol __imp__al_rest referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol __imp__al_flip_display referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol __imp__al_clear_to_color referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol __imp__al_map_rgb referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol __imp__al_create_display referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol __imp__al_install_system referenced in function _main
1>C:\Users\wboustany\Desktop\Project_Allegro\Allegro_testrun\Debug\Allegro_testrun.exe : fatal error LNK1120: 7 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I have linked the following libraires to no avail:
allegro_main-5.0.0-RC2-md.lib
allegro_main-5.0.0-RC2-mt.lib
allegro_main-5.0.0-RC2-static-md.lib
allegro_main-5.0.0-RC2-static-mt.lib

Can anyone provide guidance, I have been looking for hours now.

Thx.

Matthew Leverton
Supreme Loser
January 1999
avatar

If you link to the static libraries, you need to do this:

#define ALLEGRO_STATICLINK
#include <allegro5/allegro.h>

(Or you can put that #define in your project settings.)

Oh, and you want to link to the allegro- ... library too. The main one is not what you think it is.

Thomas Fjellstrom
Member #476
June 2000
avatar

You also need to link to the core allegro library, not just allegro_main.

--
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

Inquisiteur
Member #12,428
December 2010

Thank you for your kind answers.

Is the core library included in the file I have downloaded from here ?

http://www.allegro.cc/files/

or is it another .zip file ?

Matthew Leverton
Supreme Loser
January 1999
avatar

It is in there.

For release mode, it's easiest to use the monolithic, static, mt version. That's the only Allegro library you'd need to link with. (Additional Windows libraries like winmm.lib, opengl32.lib, glu32.lib, and psapi.lib would have to be explicitly added to the list.)

Otherwise, you need to link with allegro, allegro-main, and any add-on that you use.

Michał Cichoń
Member #11,736
March 2010

Core is just allegro-5.0.0-RC2-*.lib.

I suggest you to use allegro-5.0.0-RC2-monolith-*.lib as Matthew said.

"God starts from scratch too"
Windows Allegro Build Repo: http://targonski.nazwa.pl/thedmd/allegro/

Inquisiteur
Member #12,428
December 2010

I think it is working now, thank you all very much for your help.

Matthew Leverton
Supreme Loser
January 1999
avatar

To make things less daunting, I'll probably add a secondary minimal package on a.cc's file page. e.g., allegro-min-5.0.0-rc2-msvc-10.0.zip would contain:

  • readme.txt

  • include/*

  • lib/allegro-5.0.0-monolith-static-md.lib

  • lib/allegro-5.0.0-monolith-static-mt.lib

Michał, would anything else be needed? (I'm just using your binaries.)

Michał Cichoń
Member #11,736
March 2010

You need to include all other static libraries for dependencies like libFLAC, libOgg and others found in archive. Also for MSVC pdb files will be importand while linking to debug version (linker complain when they are missing).

Matthew, I can configure my script to prepare both: full and monolith (aka min) packages. People looks confused with naming and amount of files included, so also I will add README file.

"God starts from scratch too"
Windows Allegro Build Repo: http://targonski.nazwa.pl/thedmd/allegro/

Matthew Leverton
Supreme Loser
January 1999
avatar

Also for MSVC pdb files will be importand while linking to debug version

If they don't have the source code, the debug version isn't very useful. (The asserts might still be helpful.) Also, somebody who doesn't understand how to link with the various libraries, probably won't understand how to debug anyway... In fact, I'm not even sure I'd package the -md builds in it.

Quote:

I can configure my script to prepare both: full and monolith (aka min) packages ... so also I will add README file.

I already have a script that unarchives the packages to modify them and put them in zips. (They were 7z's on the allegro5 site.) So I was going to just create the minimal archives then and insert a readme. So it doesn't really matter to me if you do it or not.

Regarding the readme, I was just going to keep it very minimal. Something like:

Allegro 5.0.0 for MinGW 4.5

See http://www.allegro.cc/manual/5/install/windows.html for installation instructions.

(The URL might change before 5.0.0 is released.)

Michał Cichoń
Member #11,736
March 2010

PDB are there to shut up the linker, that's the main reason if you do not have sources.

Good point with README. I think a copy of this site should be included in case of offline usage.

There is an error in this site:

allegro[_module]-[version][-static,-monolith]-[mt,md][-debug]

Should be:

allegro[_module]-[version][-static][-monolith]-[mt,md][-debug]

Because monolith version can be compiled as DLL.

"God starts from scratch too"
Windows Allegro Build Repo: http://targonski.nazwa.pl/thedmd/allegro/

Matthew Leverton
Supreme Loser
January 1999
avatar

Good point with README. I think a copy of this site should be included in case of offline usage.

The main reason I like to avoid including the docs directly with the archive is that the docs are sometimes updated (particularly configuring an IDE) after the archives are created. If people download the archive and leave them sitting around, they are more apt to read from old documentation.

Those who know they will be installing offline, could just save or print out the relevant pages: the main one, and the one specific to their IDE.

Michał Cichoń
Member #11,736
March 2010

So I think URL should be exposed in README with statement "For more recent doc see: url".

Off-line version dumped at package creation time may still be included bellow it for quick reference. That's not of course the must.

"God starts from scratch too"
Windows Allegro Build Repo: http://targonski.nazwa.pl/thedmd/allegro/

Go to: