Issues with Boost Linking/Build in Dev-C++ - c++

I'm trying to compile a personal program that uses the Boost/Regex library in Orwell Dev-C++ with TDM-GCC 4.8.2 64 bit Release, and when I attempt to initialize a Boost::Regex object I get these error messages.
text$_ZN5boost9re_detail27cpp_regex_traits_char_layerIcEC2ERKNS0_21cpp_regex_traits_baseIcEE[_ZN5boost9re_detail27cpp_regex_traits_char_layerIcEC2ERKNS0_21cpp_regex_traits_baseIcEE]+0x2b): undefined reference to `boost::re_detail::cpp_regex_traits_char_layer<char>::init()'
regex_tester_main.cpp:(.text$_ZN5boost9re_detail11raw_storage6extendEy[_ZN5boost9re_detail11raw_storage6extendEy]+0x5f): undefined reference to `boost::re_detail::raw_storage::resize(unsigned long long)'
regex_tester_main.o: bad reloc address 0x5f in section `.text$_ZN5boost9re_detail11raw_storage6extendEy[_ZN5boost9re_detail11raw_storage6extendEy]'
I've followed this guide to install Boost and I used gcc as my toolkit parameters for the bootstrap.bat and the b2 builder. I've included the include and lib paths in my includes and library options. And lastly linked the appropriate libboost_regex*.a file. Before this I tried using the mingw toolkit option for the bootstrap and gcc option for b2 like the tutorial linked above does, and encountered the same errors. Can anyone shed insight into what has gone wrong?

SOLVED!
I also have the Haskell GHC installed which comes packaged with a mingw/GCC package which was located earlier in the PATH environment variable than the TDM-GCC/minGW-64 package I was aiming to use to build Boost. And so when I specified my toolset it was targeting the wrong complier and thus when I tried to build other programs with Boost it probably ran into some name-mangling issues. I removed GHC's mingw/GCC complier package from PATH and rebuilt Boost, it complies and links fine now :).

Related

Cross Compiling from Linux-Windows, stdio has undefined references (to __imp___acrt_iob_func)

As the title says, I've been trying to cross compile a fairly large project with quite a few dependencies (both static and dynamic libraries). I've cross compiled every dependency successfully using MinGW-w64, set the include & library search paths to their MinGW counterparts (/usr/x86_64-w64-mingw32/lib & include), and yet on the linking step MinGW throws out an error for each call of printf (with stdio.h included, of course). The errors are as follows:
/usr/bin/x86_64-w64-mingw32-ld: ./obj/XXXX.o:/usr/share/mingw-w64/include/stdio.h:352: undefined reference to `__imp___acrt_iob_func'
(Where "XXXX" is a file name from my project)
This error is repeated the exact same (with the exception of the object file name). The command for linking looks like this:
/usr/bin/x86_64-w64-mingw32-g++ -o bin/ReleaseWin/Project #[file with object file names] -L. -L/usr/x86_64-w64-mingw32/lib/ [linking some dependencies (boost, openGL, SDL2, etc.)...] -m64 -flto
I've searched for a solution (or even someone with the same problem) to no avail. I've never been well-versed in linking any more than regular libraries, so if you need more information just ask.
Thanks in advance :)
Extra info:
This project has been cross compiled (from Linux to Windows) successfully before, and I haven't added/removed any dependencies since.
My MinGW-w64 version is 7.0.0
So, I apt-get purge'd mingw-w64 and mingw-w64-common, reinstalled just mingw-w64, and now it's working...
This might have something to do with the fact that I followed the issue that Richard Critten commented with (thanks!), which led me to try downloading and manually copy/pasting headers and CRT (mingw-w64-x86_64-headers-git-... & mingw-w64-x86_64-crt-git) from the MSYS2 repository. That didn't work right away (probably because I screwed up and used the 5.0.0 versions instead of my version), but it seems to have done something.
Therefore, for those who stumble upon this issue,
Try a re-install of MinGW (of course),
Try manually adding the CRT and headers from the link I supplied, and if that still doesn't work,
Try re-installing MinGW again. I'm not super familiar with apt, so I don't know if adding the CRT and headers actually changed how it installed MinGW, but it's worth a shot I guess.
Update: I had this exact same problem on another system. Simply reinstalling MinGW fixed it, so it seems like maybe there was some sort of issue with the files? It's possible that updating from an earlier version messed with things. Moral of the story: even if you think your files are good, a reinstall can't hurt.

Undefined references to "__gx_personality_sj0" and others when trying to include boost::thead in project

I've recently been trying to make use of the boost libraries and whilst I have been able to include header-only libraries just fine I'm now stuck on including the linked libraries. I've managed to use b2 to build the libraries with gcc and then link to them, but whilst trying to include thread I get these errors.
I've read that these errors can be caused by using the wrong toolset for building but I can't see how I could of got that wrong as I've only ever used mingw and I used toolset=gcc when building. Here are my toolchain executables just in case I have done something wrong there. What am I doing wrong?
Turns out my path variable was incorrect and included Haskells mingw directory instead of the one I was using. After getting rid of Haskell from my path and adding the directy of the version mingw that I was using everything worked as intended.

Use of MSVC-compiled Boost binaries in a MinGW-compiled project

I've downloaded Boost Binaries from here. My project depends on boost_system and boost_filesystem, and builds correctly if I add the proper dependencies to Linker Options when using Visual Studio for compilation, but I'm now trying to compile under Code::Blocks (MinGW compiler) and running into the following:
"directve `/FAILIFMISMATCH:"_MSC_VER=1800" /FAILIFMISMATCH:"_ITERATOR_DEBUG_LEVEL=0" /FAILIFMISMATCH:"RuntimeLibrary=MD_DynamicRelease" /DEFAULTLIB:"msvcprt" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" "
Though that's a warning, it keeps me from finding the dependencies, because my project fails to build with undefined reference to 'boost::system::generic_category()' and plenty of other related undefined references.
Question: Should I compile Boost from source using MinGW, in order to solve my problem?
Of course, I'm using the proper libraries for my build configuration (Release, dynamic runtime library).
I'm making an answser based on the comments posted below my question, just to make things proper.
So, building boost from the source code using the same compiler (I used TDM-GCC with gcc 4.8.1) did solve the linking issues.
As noted by Rup, one "can't mix C++ compiled with GCC and Visual Studio: they have different C++ ABI implementations, and generate different 'manglings' of identifier names so that linker symbols won't match up."
Additional reference: Interoperability of Libraries Created by Different Compiler Brands

SjLj undefined while trying to develop a Qt application using Netbeans

Good afternoon all,
I'm trying to develop my first Qt application. I'm getting many errors like the following if I try to link in static libraries with my own code:
H:/NetBeansProjects/CommonLib/aes.cpp:607: undefined reference to `__gxx_personality_sj0'
H:/NetBeansProjects/CommonLib/aes.cpp:607: undefined reference to `_Unwind_SjLj_Register'
H:/NetBeansProjects/CommonLib/aes.cpp:615: undefined reference to `_Unwind_SjLj_Resume'
My code compiles and works when not used with Qt.
The Qt program compiled and worked before I tried to link my libraries.
Google-ing it shows it may be a mismatch between compilers used to build the two sets of code. I set the Netbeans environment to use the same tool chain to build both with no
change.
I'm using Windows, NetBeans 6.9.1, and the latest Qt. I've set the compiler to use
the Qt supplied mingw compiler.
Any suggestions?
Found the solution!
It was linking in libraries from previous versions of my projects.
I installed a new version of Mingw compiler with Qt to fix an issue. I set up the new compiler as a toolchain with a different name in Netbeans.
I did a clean and build on the referenced projects using the new tool chain. Netbeans stored the compiled library in a directory named from the tool chain. It left the old version of the library in another directory named for the original tool chain.
When you add a project reference to a library Netbeans imports the path to the library. If you change the tool chain (and therefore change the path to the library) other projects still point to the old code. You have to remove the project references and re-add them.

Including boost::filesystem produces linking errors

Ok first off, I am linking to boost_system and boost_filesystem.
My compiler is a custom build of MinGW with GCC 4.3.2
So when I include:
#include "boost/filesystem.hpp"
I get linking errors such as:
..\..\libraries\boost\libs\libboost_system.a(error_code.o):error_code.cpp:
(.text+0xe35)||undefined reference to `_Unwind_Resume'|
..\..\libraries\boost\libs\libboost_system.a(error_code.o):error_code.cpp:
(.eh_frame+0x12)||undefined reference to `__gxx_personality_v0'|
Which after a little searching I found is most commonly when you try to link a C++ program with gcc, the GNU C compiler. But I printed out the exact build command that Code::Blocks is running, and it is definitely linking with g++.
If I comment out this include, everything works fine.
Any ideas? Also, as a side, anyone know of a good place to get windows binaries for boost? The build system is giving me issues, so I'm using some binaries that came with this custom MinGW package
Ok, I found the problem. It's a bit convoluted.
GCC is gradually becoming more IS 14882 compliant in the 4.x branch. As they go on, they are removing deprecated non-standards complaint features.
While 4.1.x seem to only have them deprecated and not removed, 4.3.x seems to actually have them removed. What this means is 4.3.x and greater have some backwards compatibility issues with things compiled in the 3.x branch (which used the deprecated and now removed features)
I was using a mix and match combination of binaries that had been compiled with GCC 3.x, 4.1.x and 4.3.x so no matter which one I used, I got a similar error, because at least one binary I was linking to was incompatible with the compiler I was trying at the moment.
I'm now using GCC 4.1.2 and most of my binaries have been compiled with it. I am still how ever using a few binaries from 3.x, which is why I am not upgrading to 4.3.x just yet.
Hope that was less confusing to read than it was to write...
This seems to be a good post addressing some of the issues as they were with 4.1.x
Windows binaries: www.boost.org - see the "Getting Started" page - but if you're using g++ on MingGW you don't want those. A simple way to understand it is, MingGW is like an operating system inside an operating system so really you're not actually using Windows. The ones you've got are probably right.
Not sure what's going on with your code though, sounds like the lib files aren't linking in properly somehow. Boost names its lib files by themselves so you don't actually name them explicitly, but you have to have the lib files for boost on the right path (and make sure they're installed/built too, which they might not be). I'm not sure how to get them on the right path with g++ because I haven't used MingGW, I've only used boost with Visual Studio.