Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » [MSVC 10] Unresolved symbols when static linking to allegro 4.4.2

This thread is locked; no one can reply to it. rss feed Print
 1   2 
[MSVC 10] Unresolved symbols when static linking to allegro 4.4.2
BitCruncher
Member #11,279
August 2009
avatar

I'm trying to static link with msvc 10 using /MT.

I'm inputting allegro-4.4.2-monolith-static-mt.lib to the linker, and I've also added ALLEGRO_STATICLINK to the preprocessor, but I still get:

Error 6 error LNK1120: 5 unresolved externals
Error 4 error LNK2001: unresolved external symbol _allegro_errno
Error 2 error LNK2001: unresolved external symbol _gfx_driver
Error 3 error LNK2001: unresolved external symbol _key
Error 5 error LNK2001: unresolved external symbol _screen
Error 1 error LNK2001: unresolved external symbol _system_driver

I thought monolith meant no others libraries required (libpng, libvorbis, etc.)

EDIT: I have also specified the lib directory.

RmBeer2
Member #16,660
April 2017
avatar

You also need to specify the directory where the library is located. (-L)

🌈🌈🌈 🌟 BlackRook WebSite (Only valid from my installer) 🌟 C/C++ 🌟 GNU/Linux 🌟 IceCream/Cornet 🌟 🌈🌈🌈

Rm Beer for Emperor 2021! Rm Beer for Ruinous Slave Drained 2022! Rm Beer for Traveler From The Future Warning Not To Enter In 2023! Rm Beer are building a travel machine for Go Back from 2023! Rm Beer in an apocalyptic world burning hordes of Zombies in 2024!

BitCruncher
Member #11,279
August 2009
avatar

Did that. I can verify it because if I take out the path, I get:

Error 1 error LNK1181: cannot open input file 'allegro-4.4.2-monolith-static-mt.lib'

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

You need to define ALLEGRO_STATICLINK before including allegro if you're linking statically.

You'll also need to link the dependencies :

EDIT Sorry, I gave you A5, not A4 list

alleggl.lib
jpgalleg.lib
loadpng.lib
logg.lib
alleg-debug-static.lib
vorbis.lib
vorbisenc.lib
vorbisfile.lib
ogg.lib
png16.lib
zlibstatic.lib

kernel32.lib
user32.lib
gdi32.lib
comdlg32.lib
ole32.lib
dinput.lib
ddraw.lib
dxguid.lib
winmm.lib
dsound.lib

BitCruncher
Member #11,279
August 2009
avatar

Ok, I'll try it and give an update. I'm out of town right now.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

BitCruncher
Member #11,279
August 2009
avatar

Bump. Still not back yet...

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

RmBeer2
Member #16,660
April 2017
avatar

Bump x2 (Same day, more power)

🌈🌈🌈 🌟 BlackRook WebSite (Only valid from my installer) 🌟 C/C++ 🌟 GNU/Linux 🌟 IceCream/Cornet 🌟 🌈🌈🌈

Rm Beer for Emperor 2021! Rm Beer for Ruinous Slave Drained 2022! Rm Beer for Traveler From The Future Warning Not To Enter In 2023! Rm Beer are building a travel machine for Go Back from 2023! Rm Beer in an apocalyptic world burning hordes of Zombies in 2024!

BitCruncher
Member #11,279
August 2009
avatar

So it looks like from that list of items to link, I'm missing:

*vorbisenc.lib
*png16.lib

Just so you know, I downloaded the package from the files section on the site:

https://www.allegro.cc/files/?v=4.4

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

BitCruncher
Member #11,279
August 2009
avatar

The error now is the linker can't find dinput.lib, which is DirectInput, right?

EDIT
I went and downloaded dx70_min.zip from liballeg.org and put the libs in the VC libs directory.

Now, I'm back to the same linker errors as above except the unresolved _gfx_driver error is gone now.

_allegro_errno, _key, and _screen are all allegro, it's almost like something in the allegro static builds is missing...

EDIT #2
I got it down to 1 unresolved _main by switching from the Debug configuration to Release in VS.

DanielH
Member #934
January 2001
avatar

In your config, did you add those linker libraries to both DEBUG and RELEASE mode or just RELEASE mode?

How is your main function defined? Do you have END_OF_MAIN() at the end of main?

BitCruncher
Member #11,279
August 2009
avatar

The libs weren't included in the release configuration, but when I added them, no change.

I do have END_OF_MAIN() immediately after the closing bracket of main().

I've been researching, and I found a thread where the OP had a similar issue.

https://www.allegro.cc/forums/thread/594676

He fixed it by linking against alleg_s_crt.lib, but it must've been an earlier version of allegro than 4.4 because I don't have that file.

EDIT
Here's my code, but I don't think it's in there.

#SelectExpand
1# include <allegro.h> 2 3volatile long int coreClock = 0 ; 4 5 6void increment_coreClock () {++ coreClock ;} END_OF_FUNCTION () 7 8 9int main () 10{ 11 int screenResX = 800 ; 12 int screenResY = 600 ; 13 14 const float fullFrameRate = 60 ; // Maximum frame rate 15 float frameRatePercent = 100 ; // Percentage of the maximum frame rate that the game is run on 16 float frameRate = fullFrameRate / 100 * frameRatePercent ; // Actual frame rate that the game is run on 17 18 // Allegro initialization 19 allegro_init () ; 20 install_keyboard () ; 21 set_window_title ("") ; 22 set_color_depth (desktop_color_depth ()) ; 23 set_gfx_mode (GFX_AUTODETECT_FULLSCREEN, screenResX, screenResY, 0, 0) ; 24 install_timer () ; 25 LOCK_VARIABLE (coreClock) ; 26 LOCK_FUNCTION (increment_coreClock) ; 27 install_int_ex (increment_coreClock, BPS_TO_TIMER (frameRate)) ; 28 29 30 31 const int debugColor = makecol (0, 0, 255) ; // Color that the debugging information is written in 32 33 BITMAP* buffer = create_bitmap (screenResX, screenResY) ; 34 35 BITMAP* starBuffer = create_bitmap (1600, 1200) ; 36 BITMAP* starLayer = load_bitmap ("StarLayer2.bmp", NULL) ; 37 BITMAP* landscapeLayer = load_bitmap ("Starscape.bmp", NULL) ; 38 39 int rotateCounter [2] = {3, 3} ; 40 float rotateInc = 0.1 ; 41 float angle = 0 ; 42 43 44 45// ***************************** Begin game loop ******************************* 46 while (! key [KEY_ESC]) 47 { 48 while (! coreClock) {rest (100 / frameRate) ;} 49 while (coreClock > 0) 50 { 51 int oldTicks = coreClock ; 52 53 -- rotateCounter [0] ; 54 if (! rotateCounter [0]) 55 { 56 rotateCounter [0] = rotateCounter [1] ; 57 angle += rotateInc ; 58 } 59 60 61 62 -- coreClock ; 63 if (oldTicks <= coreClock) {break ;} 64 } 65 rotate_sprite (starBuffer, starLayer, 0, 0, ftofix (angle)) ; 66 blit (starBuffer, buffer, 400, 300, 0, 0, buffer->w, buffer->h) ; 67 draw_sprite (buffer, landscapeLayer, 0, 0) ; 68 vsync () ; 69 blit (buffer, screen, 0, 0, 0, 0, screenResX, screenResY) ; 70 } 71// ***************************** End game loop ********************************* 72 73// ***************************** Begin cleanup ********************************* 74 destroy_bitmap (buffer) ; 75 destroy_bitmap (starBuffer) ; 76 destroy_bitmap (starLayer) ; 77 destroy_bitmap (landscapeLayer) ; 78// ***************************** End cleanup *********************************** 79 return 0 ; 80} 81END_OF_MAIN ()

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

BitCruncher
Member #11,279
August 2009
avatar

Whoa okay, man. I won't link against any libraries I'm not told to. I promise.

So should I get rid of the DirectX stuff I added in the build script?

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Don't mistake my glibness for curtness.

You need some form of DX. For MSVC, that's usually taken care of by installing the DXSDK from Microsoft, but the dx7 download should work too.

I don't really know what else is wrong. If you're linking to the static allegro monolith and the dependency libraries it should work, because you've defined ALLEGRO_STATICLINK in your preprocessor defintions. The unresolved reference to _main or WinMain comes from not including END_OF_MAIN() at the end of your program, but you've done that.

Be patient, we're narrowing down the cause as best we can without being able to see your configuration.

BitCruncher
Member #11,279
August 2009
avatar

Actually, sharing my project configuration is a good idea I didn't think about.

As soon as I'm back at the cpu, I can just send the whole project, vs solution and all.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

BitCruncher
Member #11,279
August 2009
avatar

Still alive, just busy with work...

Project is attached

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

BitCruncher
Member #11,279
August 2009
avatar

I'm pretty sure I've included all the libraries you listed minus the ones I don't have.

As I said a couple posts back, I do not have:

*vorbisenc.lib
*png16.lib

They did not come with the distribution. You can see this if you go and look at the archive file for msvs 10:

https://www.allegro.cc/files/?v=4.4

I'm not sure what else I'm supposed to include...

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Well, from the pictures it looks ok. Why are the allegro libraries on the solution and not in additional dependencies? I suppose it doesn't matter.

Anyway as I said I don't have a valid license for VS anymore. Big brother Bill saw I was using MinGW-W64 and CB and got jealous.

BitCruncher
Member #11,279
August 2009
avatar

I see... Well, I'm only doing this because I'm trying to revive some old code I wrote many years ago, and it would be nice if I could distribute it without the dlls.

I'll probably try to see if I have any luck with MinGW, but if I remember correctly, trying to build allegro with MinGW on a Windows machine was always like trying to build a house of cards in a pitch black room, and you're blind. But I'll give it another shot.

If all else fails, I guess dlls aren't so bad.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

 1   2 


Go to: