CodeLite 5.3 + g++ 4.8.1 - Failure to link with libstdc++

CodeLite installation/troubleshooting forum
StasB
CodeLite Curious
Posts: 3
Joined: Thu Nov 14, 2013 8:04 pm
Genuine User: Yes
IDE Question: C++
Contact:

CodeLite 5.3 + g++ 4.8.1 - Failure to link with libstdc++

Post by StasB »

Hello!
I've set up CodeLite 5.3 to use g++ 4.8.1 by defining the following paths:

Include path: "c:\MinGW\include;c:\MinGW\lib\gcc\mingw32\4.8.1\include;c:\MinGW\lib\gcc\mingw32\4.8.1\include-fixed;c:\MinGW\lib\gcc\mingw32\4.8.1\include\c++;c:\MinGW\lib\gcc\mingw32\4.8.1\include\c++\backward;c:\MinGW\lib\gcc\mingw32\4.8.1\include\c++\mingw32;c:\MinGW\mingw32\include"

Libraries path: "c:\MinGW\lib"

Attempting to compile the following code:

Code: Select all

#include <string>

class Test {
	std::string mStr;
	
public:
	Test()
	{
	}
};

int main(int argc, char **argv)
{
	Test test;
	return 0;
}
Produces these errors:

Code: Select all

C:\Windows\system32\cmd.exe /c "mingw32-make.exe -j 4 -e -f  Makefile"
----------Building project:[ Test1 - Debug ]----------
mingw32-make[1]: Entering directory 'd:/Programs/CodeLite/Stas1/Test1'
mingw32-make[1]: Leaving directory 'd:/Programs/CodeLite/Stas1/Test1'
mingw32-make[1]: Entering directory 'd:/Programs/CodeLite/Stas1/Test1'
g++  -c  "D:/Programs/CodeLite/Stas1/Test1/main.cpp" -g -O0 -Wall  -o ./Debug/main.o -Ic:/MinGW/include -Ic:/MinGW/lib/gcc/mingw32/4.8.1/include -Ic:/MinGW/lib/gcc/mingw32/4.8.1/include-fixed -Ic:/MinGW/lib/gcc/mingw32/4.8.1/include/c++ -Ic:/MinGW/lib/gcc/mingw32/4.8.1/include/c++/backward -Ic:/MinGW/lib/gcc/mingw32/4.8.1/include/c++/mingw32 -Ic:/MinGW/mingw32/include  -I. -I.
g++ -o ./Debug/Test1 @"Test1.txt" -Lc:/MinGW/lib  -L.
./Debug/main.o:main.cpp:(.eh_frame+0x13): undefined reference to `__gxx_personality_v0'
c:/MinGW/lib/libstdc++.a(string-inst.o):string-inst.cc:(.text$_ZNSs4_Rep10_M_refcopyEv[__ZNSs4_Rep10_M_refcopyEv]+0x3a): undefined reference to `_Unwind_SjLj_Register'
c:/MinGW/lib/libstdc++.a(string-inst.o):string-inst.cc:(.text$_ZNSs4_Rep10_M_refcopyEv[__ZNSs4_Rep10_M_refcopyEv]+0x57): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: c:/MinGW/lib/libstdc++.a(string-inst.o): bad reloc address 0x57 in section `.text$_ZNSs4_Rep10_M_refcopyEv[__ZNSs4_Rep10_M_refcopyEv]'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
Test1.mk:80: recipe for target 'Debug/Test1' failed
mingw32-make[1]: *** [Debug/Test1] Error 1
mingw32-make[1]: Leaving directory 'd:/Programs/CodeLite/Stas1/Test1'
mingw32-make.exe: *** [All] Error 2
Makefile:4: recipe for target 'All' failed
3 errors, 0 warnings
However, if I comment out the std::string reference, it compiles and runs just fine. :shock:
Any clues on how this could be fixed?
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: CodeLite 5.3 + g++ 4.8.1 - Failure to link with libstdc+

Post by eranif »

StasB wrote:Hello!
I've set up CodeLite 5.3 to use g++ 4.8.1 by defining the following paths:

Include path: "c:\MinGW\include;c:\MinGW\lib\gcc\mingw32\4.8.1\include;c:\MinGW\lib\gcc\mingw32\4.8.1\include-fixed;c:\MinGW\lib\gcc\mingw32\4.8.1\include\c++;c:\MinGW\lib\gcc\mingw32\4.8.1\include\c++\backward;c:\MinGW\lib\gcc\mingw32\4.8.1\include\c++\mingw32;c:\MinGW\mingw32\include"
Switching between mingw versions is easy, do the following:

Settings -> Environment variables
Set the following:

Code: Select all

PATH=c:\MinGW\bin;$PATH
This will make sure that your gcc is the correct one

Thats it.
Remove all hard coded include paths you added and it should work (assuming that MinGW-4.8.1 is located under C:\MinGW)

Eran
Make sure you have read the HOW TO POST thread
StasB
CodeLite Curious
Posts: 3
Joined: Thu Nov 14, 2013 8:04 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: CodeLite 5.3 + g++ 4.8.1 - Failure to link with libstdc+

Post by StasB »

Removing the paths did the trick!
Thank you very much!
Post Reply