1

For almost three days now I have been trying to get the boost libs working properly in CodeBlocks using mingw. In between many of the problems that I managed to fix by myself, now I'm stuck and it's driving me mad.

I have built the library many many times with different flags sent to bjam but every time I use these libs in CodeBlocks I get the same result. A lot of lines with

undefined reference to `___gxx_personality_sj0'
undefined reference to `__Unwind_SjLj_Register'
undefined reference to `__Unwind_SjLj_Resume'
undefined reference to `__Unwind_SjLj_Unregister'

Before people start lashing out at me, I have searched for the problem before coming here. Almost all the threads (here and here and others) say that this problem comes from the fact that boost was built with a compiler and now I am trying to use another different compiler in CodeBlocks. I have checked time and time again and I only have one MinGW installation available. I have checked my Path variable and nothing unwanted is in there, only the bin folder of the MinGW that I want to use. I don`t have any QT installation so no second MinGW from there. Also, I downloaded the CodeBlocks without the bundled MinGW.

Below I will list the steps I take:

1) bootstrap.bat mingw which builds bjam

2) bjam --toolset=gcc "--prefix=<installpath>" install as stated here

3) follow the rest of the steps from the link from step 2)

4) add Boost.Filesystem, Boost.System, Boost.DateTime, Boost.Thread and Boost.Regex (dependencies for Boost.Log taken from here)

5) copy/paste this example

The command that CodeBlocks uses when I try to Build:

mingw32-g++.exe -Wall -fexceptions -g
-ID:\libs\boost\include\boost-1_51 -c D:\example\example\main.cpp -o obj\Debug\main.o

mingw32-g++.exe -LD:\libs\boost\lib -o bin\Debug\example.exe obj\Debug\main.o D:\libs\boost\lib\libboost_filesystem-mgw44-mt-d-1_51.a D:\libs\boost\lib\libboost_system-mgw44-mt-d-1_51.a D:\libs\boost\lib\libboost_date_time-mgw44-mt-d-1_51.a D:\libs\boost\lib\libboost_thread-mgw44-mt-1_51.a D:\libs\boost\lib\libboost_regex-mgw44-mt-d-1_51.a D:\libs\boost\lib\libboost_log_setup-mgw44-mt-d-1_51.a

What else could be the cause of this?

Later added:

CodeBlocks toolchain executables are:

c++ compiler: mingw32-g++.exe
linker for dynamic libs: mingw32-g++.exe
linker for static libs: ar.exe

All .EXEs are where they should be but added this info maybe it is important.

Community
  • 1
  • 1
  • What version of MinGW are you using, and how did you install it? (You aren't doing anything obviously wrong...) – Mankarse Aug 22 '12 at 11:55
  • I use mingw-get from the command line (graphical interface doesn't work for me for some reason...). last time i installed it i did a `mingw-get install gcc g++` –  Aug 22 '12 at 12:13

1 Answers1

0

Fixed the problem. After Mankarse asked me about the gcc version I checked and it was the same as used to compile the libs (4.4). I decided to upgrade to the latest version (4.7) and try again. After updating I noticed that the compiled libs still had mgw44 in their names which made me think that maybe I did have a second mingw installation.

After checking out every folder I had in my Path variable, I came to the conclusion that Strawberry Perl which I had installed some weeks ago, also came bundled with a version of gcc. After I removed it and rebuilt boost from sctratch, the errors vanished.

For future reference if someone comes across this problem again and is sure that he only has one mingw, just check again like this:

  1. remove the bin folder with mingw exes from your Path variable

  2. open a command prompt and type g++. If it say something like g++: fatal error: no input files then you have more than one mingw installations.