0

Hi I'm trying to link a Boost Log simple example with mingw32 on Windows 8 and I'm getting link errors:

Log.cpp

#include <boost/log/trivial.hpp>

int main()
{

    BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
    BOOST_LOG_TRIVIAL(debug) << "A debug severity message";
    BOOST_LOG_TRIVIAL(info) << "An informational severity message";
    BOOST_LOG_TRIVIAL(warning) << "A warning severity message";
    BOOST_LOG_TRIVIAL(error) << "An error severity message";
    BOOST_LOG_TRIVIAL(fatal) << "A fatal severity message";
}

And I'm running the following compile and link command

gcc -Wall -g -static -I./../../boost_1_56_0/ Log.cpp -o Log.exe -L./../../boost_1_56_0/stage/lib/ -lboost_log-mgw48-mt-1_56 -lboost_thread-mgw48-mt-1_56 -lboost_system-mgw48-mt-1_56 -lstdc++

And I'm getting the following errors:

C:\SpellSpindle\GelatinousEngine\BoostHelloWorld\Log>mingw32-make
g++ -Wall -g -static -I./../../boost_1_56_0/ Log.cpp -o Log.exe -L./../../boost_
1_56_0/stage/lib/ -lboost_log-mgw48-mt-1_56 -lboost_thread-mgw48-mt-1_56 -lboost
_system-mgw48-mt-1_56 -lstdc++
./../../boost_1_56_0/stage/lib/\libboost_thread-mgw48-mt-1_56.a(thread.o):thread
.cpp:(.text$_ZN5boost6detail5win3223GetTickCount64emulationEv+0x1e): undefined r
eference to `_InterlockedCompareExchange'
./../../boost_1_56_0/stage/lib/\libboost_thread-mgw48-mt-1_56.a(thread.o):thread
.cpp:(.text$_ZN5boost6detail5win3223GetTickCount64emulationEv+0x77): undefined r
eference to `_InterlockedCompareExchange'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: ./../../bo
ost_1_56_0/stage/lib/\libboost_thread-mgw48-mt-1_56.a(thread.o): bad reloc addre
ss 0x77 in section `.text$_ZN5boost6detail5win3223GetTickCount64emulationEv'
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
Makefile:15: recipe for target 'all' failed
mingw32-make: *** [all] Error 1

I've been trying to get this to link for days and haven't found anything posted on the internet that fix the link errors.

Can anyone help?

2 Answers2

0

Stitching together information from different websites:

sehe
  • 374,641
  • 47
  • 450
  • 633
  • I have mingw 4.8.1. I had built the boost libraries for mingw 4.8 but I rebuilt them for 4.8.1 and they still don't compile, giving the same errors. – Anytime0 Oct 06 '14 at 22:21
  • I was building them with "boostrap mingw", "bjam --toolset=gcc-4.8.1 --build-type=complete". Is there some other way of building them that will work for mingw 4.8.1? I tried installing Mingw-W64 but when installing it I get an "Error Res" message. And it doesn't install anything I can compile with. I see there's a backward compatability error but the first time i had tried to build and use boost was with mingw 4.8.1. Is the problem still the backwards compatability or is it something else? – Anytime0 Oct 06 '14 at 22:27
  • You're saying the that mingw 4.8 broke the boost build, but is there any way it can work now? Is it still broken? – Anytime0 Oct 06 '14 at 22:37
0

The installer for Mingw-W64 didn't work but after I downloaded it from the repository manually I was able to get the thing working. I rebuilt the boost libraries for mingw version 4.9.1 and then it did link to the new libraries. Thank you greatly! Woohoo!