BOOST link problem related to the migration of Qt4 to Qt5 using MinGW on Windows
I am doing the migrating from Qt4 to Qt5 using the compiler MinGW on Windows 7, and I get link errors with BOOST.
..\libboost_serialization-mgw49-mt-s-1_59.a(archive_exception.o):-1: error: duplicate section `.rdata$_ZTSN5boost7archive17archive_exceptionE[__ZTSN5boost7archive17archive_exceptionE]' has different size
I am using:
Desktop Qt 5.5.0 MinGW 32bit
The compiler is MinGW 4.9.2
boost version 1.59
I have compiled the boost library "serialization" with the same compiler as my Qt application.
I have tried to use the same compiler options.
I have not this problem with Qt4.
Thanks for helping
@Claude I fixed my problem by using MinGW 4.8.2 32bit in order to compile both: Boost 1.59 and my application using Qt 5.5.0.
I don't have the bug with the MinGW versions prior to the 4.8.2 version, but I have the bug with the 4.9.1 and 4.9.2 versions.
Hi and welcome to devnet,
That might come from a difference between the compiler options used to build boost and Qt.
@SGaist I have tried re-compiling boost with the same default options generated by Qt for my application and I got the problem. Maybe, these options are different from the ones used to compile the Qt libraries, but I don't know these ones.
You should be able to get that information from Qt's mkspec
I have replaced the boost library "serialization" by the QDataStream class and I have removed completely boost from my environment of development.
I have activated the c++11/14 language by adding CONFIG += c++14 in my .pri file.
I am using Qt5.5.0 with MinGW 4.9.2 32bit.
This way, my application and the Qt libraries are compiled with the same compiler and the same compilation options, and I can get access to the new C++ features of c++11/14 instead of using boost.
Also, by eliminating this boost dependence, I will be able to migrate to the next versions of Qt and to the next c++17 to be coming.
Happy coding :)
Sorry for digging up this thread but I have the same problem with boost::serialization and MinGW.
I want to port my software from Qt4.8 with MinGW 4.6 to the newest 5.5 MinGW 4.9+ but still with the boost::serialization in use. I have compiled boost libraries with compiler provided with Qt (4.9.2), but still got linker errors:
./release\xxx.o:xxx.cpp:(.text$_ZN5boost13serialization15throw_exceptionINS_7archive17archive_exceptionEEEvRKT_[__ZN5boost13serialization15throw_exceptionINS_7archive17archive_exceptionEEEvRKT_]+0x1d): undefined reference to `vtable for boost::archive::archive_exception' collect2.exe: error: ld returned 1 exit status
Maybe someone came up with a solution for this tricky problem?
Hi and welcome to devnet,
Do you have boost built also in release mode ? For the same architecture ?
As you suggested I putted my eye on architecture (build type was ok) and I found where the problem was. Well, a part of it at least :).
There were in fact two issues:
- a) wrong address model. Default boost build with mingw492 did a “address-model=32”, I had to change it to “address-model=32_64” explicit.
- b) wrong library type. I used a shared library so far. When I switched to static, it went smooth.
I can stand the a), but I’m wondering why the b) was the issue? I’m using bunch of other boost libraries from the same package in shared and there were no problems at all.
Anyway, for me we can call it "solved".
For b, check whether the library has other dependencies. You might be missing one.