![]() |
|
Static linking in VS2010 and A5 is giving errors |
André Silva
Member #11,991
May 2010
![]() |
Sorry to bother, but I just can't find the answer myself. I'm trying to statically link Allegro 5 on Visual Studio 2010, but it's not working. I checked on the forums and Google and did all the steps that I could gather (release build):
But I keep getting errors like allegro-5.0.7-static-mt.lib(wxthread.obj) : error LNK2001: unresolved external symbol __imp__timeGetTime@0 I tried making sure the ALLEGRO_STATICLINK #define was well written (if it's wrong, it gives different errors), tried /MD, tried the -md.lib libraries (I get a OLDNAMES.lib(unlink.obi) : error LNK2001: unresolved external symbol __imp___unlink error in this case), tried having the inherit from parent or project defaults option checked, tried --static, I just tried everything. There is no good tutorial out there for how you statically link with Allegro 5 on VS2010. I don't even know exactly what the effects are. With this, I know the dlls are "bundled" with the executable. This means I won't have to distribute the Allegro dlls or MSVCR100.dll with the program, right? Someone has to know!...
|
Arthur Kalliokoski
Second in Command
February 2005
![]() |
Try linking winmm.lib? They all watch too much MSNBC... they get ideas. |
Cassio Renan
Member #14,189
April 2012
![]() |
Try checking the wiki for the VS2008 installation. It's not the same version, but some things still apply. here: http://wiki.allegro.cc/index.php?title=Windows,_Visual_Studio_2008_and_Allegro_5 |
André Silva
Member #11,991
May 2010
![]() |
Odd, from what I've read around then, I should have opengl32.lib, gdiplus.lib, winmm.lib, psapi.lib on my Allegro 5's lib folder. Is this true? If not, does this mean I'll have to obtain those dlls somewhere else?
|
Trent Gamblin
Member #261
April 2000
![]() |
They come with Windows/MSVC, you don't need to do anything but link to them (I think that usually means just writing "winmm" where you link libraries in MSVC -- but I'm not an MSVC user.)
|
Cassio Renan
Member #14,189
April 2012
![]() |
Nope, it is not. I can't say for MSVC, but for MinGW they're all on the compiler's lib folder. You should check for such folder on your VS's installation. EDIT: Trent was faster. |
André Silva
Member #11,991
May 2010
![]() |
On my machine, those files were on C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib Regardless, I added them to the list of libraries, even without specifying the folder, and it found them... but it's giving off different errors this time. allegro-5.0.7-static-md.lib(fshook_stdio.obj) : error LNK2001: unresolved external symbol __imp___stat64i32 ... OLDNAMES.lib(unlink.obi) : error LNK2001: unresolved external symbol __imp__unlink ... freetype-2.4.8-static-md.lib(psmodule.obj) : error LNK2001: unresolved external symbol __imp__qsort ... OLDNAMES.lib(fdopen.obi) : error LNK2001: unresolved external symbol __imp___fdopen
|
Arthur Kalliokoski
Second in Command
February 2005
![]() |
Now MS can't even find libc? Switch to Mingw and stay there. They all watch too much MSNBC... they get ideas. |
André Silva
Member #11,991
May 2010
![]() |
Excellent advice. But I did try compiling with g++ via command line once, without static linking. When I tried running it on another machine, it complained about libgcc or some such. I figure I'll have to add those libraries to the linker, sure, but seeing as we're on the topic, would I need to link anything else?
|
torhu
Member #2,727
September 2002
![]() |
http://wiki.allegro.cc/index.php?title=Windows,_Visual_Studio_2008_and_Allegro_5#Linker_Settings Go back to what you originally did, but add the missing Windows libraries. EDIT: If you want a better IDE, get Visual Studio 2008. Microsoft kind of lost their way after that. |
Arthur Kalliokoski
Second in Command
February 2005
![]() |
torhu said: Microsoft kind of lost their way after that. Aren't they changing to the They all watch too much MSNBC... they get ideas. |
André Silva
Member #11,991
May 2010
![]() |
Ok, I have allegro-5.0.7-static-mt.lib allegro_font-5.0.7-static-mt.lib allegro_image-5.0.7-static-mt.lib allegro_primitives-5.0.7-static-mt.lib allegro_ttf-5.0.7-static-mt.lib dumb-0.9.3-static-mt.lib freetype-2.4.8-static-mt.lib libFLAC-1.2.1-static-mt.lib libogg-1.2.1-static-mt.lib libvorbis-1.3.2-static-mt.lib libvorbisfile-1.3.2-static-mt.lib openal-1.14-static-mt.lib zlib-1.2.5-static-mt.lib winmm.lib opengl32.lib gdiplus.lib psapi.lib msvcrt.lib libcmt.lib shlwapi.lib added, and it did compile this time! Problem though: It didn't do anything, as the executable still asked for msvcr100.dll when trying to run on a different machine. The Allegro libraries were successfully packaged though, because when I tried pasting msvcr100.dll onto the folder, it worked, even though the graphics were garbled. So while it did package the Allegro libs, it didn't package the runtime libs. Still not resolved then... I also found this thread, which I failed to find beforehand, but nothing there was able to help me either. Also I just checked again to be sure. /MT, the ALLEGRO_STATICLINK #define is fine, everything seems to be in order. Guess I should just turn to MinGW and Eclipse, huh. But can we at least try to find the solution? At least if not for me, for anyone else who stumbles upon this thread and tries to statically link.
|
torhu
Member #2,727
September 2002
![]() |
André Silva said: msvcrt.lib Remove those, the compiler adds them based on the /MT and /MD setting. libcmt.lib is the static C runtime, while msvcrt.lib is the import library for msvcr100.dll |
André Silva
Member #11,991
May 2010
![]() |
Hah! It worked! Thank you. So, to recap, in order to statically link Allegro 5 and the Visual C++ runtimes on Visual Studio 2010...
I tried creating a tiny program following these steps, and it worked. There was only the executable on the folder, I ran it, and it didn't ask for any Allegro library or for MSVCR100.dll. I hope this helps whoever has the same problem as me!
|
Thomas Fjellstrom
Member #476
June 2000
![]() |
Note that some of those libs are optional if you don't use some of the addons. (vorbis, flac, freetype, openal, etc). -- |
Cassio Renan
Member #14,189
April 2012
![]() |
Since it seems that you got it summed up nicely, I guess this could go into the wiki. I could do it myself, but right now I don't have the time(also, I'm running ubuntu, so I can't do nothing more than copy/paste stuff here, unable to test anything). I can do it later this week, though, if nobody applies for the job. |
André Silva
Member #11,991
May 2010
![]() |
I have experience with wikis, and honestly, I don't think this'll take that long to do. I'll handle it tomorrow!
|
|