![]() |
|
How to fix error -lstdc++ ? |
jomi77
Member #14,799
December 2012
|
Hello all. I'm having a problem that I can't seem to figure out. Whenever I build and run the test program to check if Allegro 5 works, I get this error: ld.exe cannot find -lstdc++ This is the code: #include <allegro5\allegro.h> int main(void) if(!al_init()) display = al_create_display(640, 480); if(!display) al_destroy_display(display); I've watched about 5 different video tutorial on youtube on how to link all the bin, include and lib files so I'm really confused as to why I'm getting this error. I'm using allegro-5.0.8-mingw-4.6.2 and CodeBlocks 10.5 If anyone can help I would appreciate it a ton. |
Arthur Kalliokoski
Second in Command
February 2005
![]() |
Thing to try that might help: As root (sudo) say "ldconfig" Or "set | grep LD_LIBRARY_PATH" and check that the directory the Allegro libs are in is listed. They all watch too much MSNBC... they get ideas. |
jomi77
Member #14,799
December 2012
|
Hello Arthur, could you explain how exactly to do that? I am a complete noob and didn't even know about Allegro a week ago. Also, is the order in which I include the files in CodeBlocks really that important? I just copy and pasted the files like I saw in the tutorials I watched and it seemed to work for them. Last question what is the difference between dynamic linking and static linking? Sorry for all the questions. |
Arthur Kalliokoski
Second in Command
February 2005
![]() |
I just now saw the ".exe" at the end of ld, and what I posted above was for linux. As for windows, I guess you're using Mingw? Probably wrong environment variables again. Try typing these lines in from a command prompt and start Codeblocks from that. set MINGDIR=c:\mingw set C_INCLUDE_PATH=<whereever you've unpacked the Allegro files\include> set path=%path%;c:\mingw\bin That's not really how it should be done, but I don't remember all the rigamarole needed in control panel to set them permanently. They all watch too much MSNBC... they get ideas. |
LennyLen
Member #5,313
December 2004
![]() |
Can you build a simple "Hello World" application? My guess is that you're missing part of the MinGW package.
|
jomi77
Member #14,799
December 2012
|
LennyLen I just tried to make a Hello World app and got the same error. I think that is the problem, but how can I fix it? I could make a Hello World app before just fine. |
LennyLen
Member #5,313
December 2004
![]() |
You could just try removing the current MinGW installation and reinstall it from scratch.
|
Arthur Kalliokoski
Second in Command
February 2005
![]() |
LennyLen said: You could just try removing the current MinGW installation and reinstall it from scratch. Huh. Windows.
They all watch too much MSNBC... they get ideas. |
jomi77
Member #14,799
December 2012
|
The only MINGW I have is what I downloaded with CodeBlocks. I guess I'll just try again later and uninstall everything and start from scratch again. Thanks. |
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
What are you guys talking about? WTF...??? - Dont pass -lstdc+++ to the compiler. It is not necessary. MinGW automatically links to the standard c++ library for you when you use g++ or mingw32-g++. If you want to link to the c and c++ libraries statically so you don't have to drag around those dlls, then use something like : My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
LennyLen
Member #5,313
December 2004
![]() |
Edgar Reynaldo said: Dont pass -lstdc+++ to the compiler. It is not necessary. MinGW automatically links to the standard c++ library for you when you use g++ or mingw32-g++. If you want to link to the c and c++ libraries statically so you don't have to drag around those dlls, then use something like : He said he was following A5 tutorials, and none of them link directly to libstc++, so it's fairly safe to assume that jomi77 isn't doing so either. Hence why I'm inclined to think that his MinGW installation has been corrupted somehow.
|
jomi77
Member #14,799
December 2012
|
Ok so I unistalled CodeBlocks and downloaded the newest version. I can now run a Hello World program succesfully. I linked the libraries but now I get these errors: line 8 undefined reference to al_install_system and two warnings: line 10 warning: passing NULL to non-pointer argument 6 of int al_show_native_message_box(ALLEGRO_DISPLAY*, const_char*, const_char*, const_char*, ) line 18 warning: passing NULL to non-pointer argument 6 of int al_show_native_message_box(ALLEGRO_DISPLAY*, const_char*, const_char*, const_char*, ) Any idea as to what the problem might be this time? |
Arthur Kalliokoski
Second in Command
February 2005
![]() |
The undefined references come failure to link the libraries and the warnings are from using native message box incorrectly. They all watch too much MSNBC... they get ideas. |
billyquith
Member #13,534
September 2011
|
libc++ is the new C++11 library for LLVM clang. libstdc++ is the GCC version. You cannot mix these. libc++: http://libcxx.llvm.org |
|