Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » static link problem

This thread is locked; no one can reply to it. rss feed Print
static link problem
shadyvillian
Member #12,426
December 2010

I'm trying to to a static link so I dont have to use the dll's. I used this tutorial - Allegro.cc

I'm pretty sure I followed everything right, but when i compile and run it get this during the linking exe: collect2: ld returned 5 exit status. what does this mean?

Software Engineer by day, hacker by night.

Trent Gamblin
Member #261
April 2000
avatar

It means you didn't post enough of the error for us to figure out what went wrong :o.

shadyvillian
Member #12,426
December 2010

I've attached a screenshot.

Software Engineer by day, hacker by night.

AMCerasoli
Member #11,955
May 2010
avatar

Try Re-running the MinGW installer.

shadyvillian
Member #12,426
December 2010

didn't seem to do anything.

Software Engineer by day, hacker by night.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

It looks like you are using Code::Blocks - post the build log it creates (there should be a file named PROJECTNAME_build_log.html in the same folder as your project). That will show the commands used to link your program. Which version of MinGW are you using?

shadyvillian
Member #12,426
December 2010

I'm not sure on my mingw version it says gcc 4.4.1 on the code blocks welcome screen. heres the log

Build started on: 20-04-2011 at 15:01.29
Build ended on: 20-04-2011 at 15:01.31
-------------- Build: Debug in MTG DeckBuilder ---------------
mingw32-g++.exe -LC:\Users\Aaron\Documents\allegro-5.0.0-mingw-4.5.0\lib -L"C:\Program Files\CodeBlocks\lib" -o "bin\Debug\MTG DeckBuilder.exe" obj\Debug\Main.o

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\liballegro-5.0.2-static-mt.a

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\liballegro_acodec-5.0.2-static-mt.a

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\liballegro_audio-5.0.2-static-mt.a

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\libvorbisfile-1.3.2-static-mt.a

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\libvorbis-1.3.2-static-mt.a

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\liballegro_color-5.0.2-static-mt.a

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\liballegro_dialog-5.0.2-static-mt.a

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\liballegro_font-5.0.2-static-mt.a

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\liballegro_image-5.0.2-static-mt.a

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\liballegro_memfile-5.0.2-static-mt.a

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\liballegro_physfs-5.0.2-static-mt.a

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\liballegro_primitives-5.0.2-static-mt.a

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\liballegro_ttf-5.0.2-static-mt.a

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\libdumb-0.9.3-static-mt.a

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\libFLAC-1.2.1-static-mt.a

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\libfreetype-2.4.4-static-mt.a

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\libogg-1.2.1-static-mt.a

C:\Users\Aaron\Documents\allegro-5.0.2-1-mingw-4.5.0\lib\libzlib-1.2.5-static-mt.a

C:\MinGW\lib\libgdiplus.a
C:\MinGW\lib\libuuid.a
C:\MinGW\lib\libkernel32.a
C:\MinGW\lib\libwinmm.a
C:\MinGW\lib\libpsapi.a
C:\MinGW\lib\libopengl32.a
C:\MinGW\lib\libglu32.a
C:\MinGW\lib\libuser32.a
C:\MinGW\lib\libcomdlg32.a
C:\MinGW\lib\libgdi32.a
C:\MinGW\lib\libshell32.a
C:\MinGW\lib\libole32.a
C:\MinGW\lib\libadvapi32.a
C:\MinGW\lib\libws2_32.a -mwindows

collect2: ld returned 5 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
0 errors, 0 warnings

EDIT: I changed the mingw directory to the one i downloaded and it seemed to work. but now i get 73 warnings saying i cant use null like this:

warning: passing NULL to non-pointer argument 6 of 'int al_show_native_message_box(ALLEGRO_DISPLAY*, const char*, const char*, const char*, const char*, int)'

why does it say this now and not before? Does this mean I have to use 0 instead of null now?

Software Engineer by day, hacker by night.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

build log said:

-L"C:\Program Files\CodeBlocks\lib"

That path has a space in it. MinGW is notorious for not liking spaces in paths. Move the libraries that you have there to another folder. Also make sure MinGW is not installed to a path that has spaces in it. If it is, you'll need to reinstall MinGW, to a folder like 'c:\mingw'.

Second, you can get the exact version of mingw installed by cd'ing to the mingw\bin directory and typing 'mingw32-gcc --v'. Some versions of MinGW earlier than 4.5.0 could not statically compile Allegro 5, and so they may have trouble statically compiling programs that depend on Allegro 5 as well.

Third, version 4.4.1 may not be compatible with the binary download package for version 4.5.0. Install MinGW 4.5.0.

Edit for your edit

warning: passing NULL to non-pointer argument 6 of 'int al_show_native_message_box(ALLEGRO_DISPLAY*, const char*, const char*, const char*, const char*, int)'

NULL is a pointer, and is therefore, not an int. The manual page for al_show_native_message_box is not very clear, but the last parameter should be one of the flags there, like ALLEGRO_MESSAGE_BOX_OK_CANCEL.

Arthur Kalliokoski
Second in Command
February 2005
avatar

MinGW is notorious for not liking spaces in paths.

Not even when it's enclosed by double quotes as in the post?

They all watch too much MSNBC... they get ideas.

shadyvillian
Member #12,426
December 2010

Well its saying that for all null parameters and if i change null to 0 the warning goes away. I thought null was 0?

Software Engineer by day, hacker by night.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Well its saying that for all null perimeters and if i change null to 0 the warning goes away. I thought null was 0?

No, NULL is usually defined as (void*)0, which is not an integer. In C++ you have to make an explicit cast to go between an integer and a pointer.

Arthur Kalliokoski
Second in Command
February 2005
avatar

IIRC, NULL is usually "(void *) 0" and not just an int 0.

They all watch too much MSNBC... they get ideas.

shadyvillian
Member #12,426
December 2010

Is there a way to remove the dependency for libgcc_s_dw2-1 and libstdc++-6? I can run the exe with no dlls on my computer but when I run the program on another computer it wants those dlls(maybe others im not sure)

Software Engineer by day, hacker by night.

Oscar Giner
Member #2,207
April 2002
avatar

In C++ NULL is defined as just 0.

C++0x introduces nullptr.

Go to: