recently I treid to add Allegro5 library to Visual Studio 2010. I visited allegro.cc and downloaded package called: allegro-5.0.4-msvc-10.0 (following the name, I think it's correct one) and after extracxtion, and I copied:
/bin to C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
/include to C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include
/lib to C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib
Allegro's dlls to C:\Windows\System32
I also added "alld.lib" in project -> properties -> linker -> input
And when I tried to use Allegro in my project, I could included Allegro's headers but it's an error when I tried to type something simple like:
#include <allegro5\allegro.h>
int main()
{
allegro_init()开发者_高级运维;
return 0;
}
It generates an error (red underline in typing mode) : undefinded identifier "allegro_init". Would anyone give me a tip what might be wrong in this configuration? I'll be very glad for all hints and solutions. Greetings,
Please see the documentation on the wiki for Allegro 5 and Visual Studio 2010. Especially note the bit about not modifying system folders like you have already done.
Anyway, the problem here is that you are trying to write Allegro 4 code but you've installed Allegro 5. The two are not compatible. Allegro 5 is completely rewritten and designed for modern hardware. The correct equivalent program is:
#include <allegro5/allegro.h>
int main(int argc, const char *argv[])
{
al_init();
return 0;
}
Also, you are linking with Allegro 4, judging by the name of the file. The libraries as included in the binary package are described here. There are many different versions included for debugging, for static run times, etc. The most direct equivalent for alld.lib
is allegro-5.0.4-monolith-md-debug.lib
.
You can find the manual here: http://www.allegro.cc/manual/5/
Well your big problem is, I'd guess, that you aren't actually telling the linker how to load the DLL.
You could do it manually using LoadLibrary and GetProcAddress.
However most of the time when you build a DLL you'll find you get a library which handles all the above dynamic linking for you. As a result you'll find its much easier to just add that lib to the linker "inputs".
精彩评论