Page 1 of 1

Error compiling with CodeBlocks and Mingw

Posted: 09 Feb 2015, 01:18
by codemannz
Hi everyone,

I am using CodeBlocks 13.12 with the mingw compiler. I downloaded spring using this:
git clone --recursive git://github.com/spring/spring.git -b develop
cd spring
git clone https://github.com/spring/mingwlibs

Then I created the CodeBlocks project file using cmake-gui. I set the source code path to "C:\spring" and the build directory to "C:\spring\build" and clicked Generate.

Then I opened the project in CodeBlocks and compiled it. Everything was going fine until I get these errors:

Code: Select all

../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x2a2): undefined reference to `_InterlockedCompareExchange'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x2d0): undefined reference to `_InterlockedCompareExchange'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x344): undefined reference to `_InterlockedExchange'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x406): undefined reference to `_InterlockedIncrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x426): undefined reference to `_InterlockedCompareExchange'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x6c1): undefined reference to `_InterlockedIncrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x6e6): undefined reference to `_InterlockedCompareExchange'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0xb12): undefined reference to `_InterlockedCompareExchange'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0xb40): undefined reference to `_InterlockedCompareExchange'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0xbb4): undefined reference to `_InterlockedExchange'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0xca3): undefined reference to `_InterlockedIncrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0xcc3): undefined reference to `_InterlockedCompareExchange'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0xe41): undefined reference to `_InterlockedIncrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0xe66): undefined reference to `_InterlockedCompareExchange'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x10ad): undefined reference to `_InterlockedIncrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x1184): undefined reference to `_InterlockedIncrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x11f6): undefined reference to `_InterlockedIncrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x121b): undefined reference to `_InterlockedIncrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x1228): undefined reference to `_InterlockedDecrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x12a7): undefined reference to `_InterlockedIncrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x12b4): undefined reference to `_InterlockedDecrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x131a): undefined reference to `_InterlockedDecrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x136a): undefined reference to `_InterlockedDecrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x13ef): undefined reference to `_InterlockedIncrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x141a): undefined reference to `_InterlockedDecrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x14f3): undefined reference to `_InterlockedIncrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x152c): undefined reference to `_InterlockedDecrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x15fb): undefined reference to `_InterlockedIncrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x1606): undefined reference to `_InterlockedDecrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x1669): undefined reference to `_InterlockedIncrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x2dd2): undefined reference to `_gmtime32'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x3cf6): undefined reference to `_InterlockedIncrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x3d88): undefined reference to `_InterlockedDecrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x3d9e): undefined reference to `_InterlockedDecrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x3ec2): undefined reference to `_InterlockedIncrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x3f4f): undefined reference to `_InterlockedDecrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x3fd2): undefined reference to `_InterlockedDecrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x40c5): undefined reference to `_InterlockedIncrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x40d9): undefined reference to `_InterlockedDecrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text$_ZN5boost6detail21intrusive_ptr_releaseEPNS0_16thread_data_baseE[__ZN5boost6detail21intrusive_ptr_releaseEPNS0_16thread_data_baseE]+0x11): undefined reference to `_InterlockedDecrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text$_ZN5boost6detail20rollback_once_regionERNS_9once_flagERNS0_12once_contextE[__ZN5boost6detail20rollback_once_regionERNS_9once_flagERNS0_12once_contextE]+0x1b): undefined reference to `_InterlockedExchange'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text$_ZN5boost6detail24basic_condition_variable10notify_allEv[__ZN5boost6detail24basic_condition_variable10notify_allEv]+0x57): undefined reference to `_InterlockedCompareExchange'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text$_ZN5boost6detail24basic_condition_variable10notify_allEv[__ZN5boost6detail24basic_condition_variable10notify_allEv]+0x95): undefined reference to `_InterlockedCompareExchange'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text$_ZN5boost6detail24basic_condition_variable10notify_allEv[__ZN5boost6detail24basic_condition_variable10notify_allEv]+0xd0): undefined reference to `_InterlockedExchange'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text$_ZN5boost6detail24basic_condition_variable10notify_allEv[__ZN5boost6detail24basic_condition_variable10notify_allEv]+0x134): undefined reference to `_InterlockedCompareExchange'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text$_ZN5boost6detail24basic_condition_variable10notify_allEv[__ZN5boost6detail24basic_condition_variable10notify_allEv]+0x1b4): undefined reference to `_InterlockedDecrement'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text$_ZN5boost6detail24basic_condition_variable10notify_allEv[__ZN5boost6detail24basic_condition_variable10notify_allEv]+0x2b8): undefined reference to `_InterlockedCompareExchange'
../../../mingwlibs/lib/libboost_thread-mt.a(thread.o):thread.cpp:(.text$_ZN5boost6detail24basic_condition_variable10notify_allEv[__ZN5boost6detail24basic_condition_variable10notify_allEv]+0x346): undefined reference to `_InterlockedCompareExchange'

Re: Error compiling with CodeBlocks and Mingw

Posted: 09 Feb 2015, 01:26
by abma
which compiler did you use? could be this bug: https://svn.boost.org/trac/boost/ticket/10296

did you follow this guide?

http://springrts.com/wiki/Building_Spring_on_Windows

Re: Error compiling with CodeBlocks and Mingw

Posted: 09 Feb 2015, 01:34
by codemannz
I am using Minw32 version 3.2

Yes I followed that guide. The only thing I didn't do was Installing MinGW-w64 since I already had it installed through CodeBlocks.

Re: Error compiling with CodeBlocks and Mingw

Posted: 09 Feb 2015, 01:38
by abma
codemannz wrote:Yes I followed that guide. The only thing I didn't do was Installing MinGW-w64 since I already had it installed through CodeBlocks.
very likely because of that you get that error. you can try to apply the two commits from the boost ticket, this should fix the error you got.

Re: Error compiling with CodeBlocks and Mingw

Posted: 09 Feb 2015, 20:33
by codemannz
Following those steps fixed the issue. But now I get this:
../../../mingwlibs/lib/libcurl.a(easy.o):easy.c:(.text+0x791): undefined reference to `WSACleanup@0'
../../../mingwlibs/lib/libcurl.a(easy.o):easy.c:(.text+0x7bb): undefined reference to `WSAStartup@8'
../../../mingwlibs/lib/libcurl.a(easy.o):easy.c:(.text+0x7d7): undefined reference to `WSACleanup@0'
../../../mingwlibs/lib/libcurl.a(easy.o):easy.c:(.text+0x7f0): undefined reference to `WSACleanup@0'

Re: Error compiling with CodeBlocks and Mingw

Posted: 09 Feb 2015, 20:41
by abma
i can only guess as in the snipped you gave the target which fails is missing. try to add in tools/pr-downloader/src/CMakeLists.txt

below

Code: Select all

target_link_libraries(Downloader
add

Code: Select all

ws2_32

Re: Error compiling with CodeBlocks and Mingw

Posted: 09 Feb 2015, 21:00
by Super Mario
You can have specify on what compiler to use when generating the project files using cmake. Have you try that already?