Linking Problem with MinGW binary distribution and QT
Added by Michael Möllney over 3 years ago
Hi
Sorry if this is handled somewhere else. I found a message with answer giving hints how to use the prebuild exiv2 MinGW version with Qt but this does not seem to work with my installation.
The messges I found are using MinGW 4.9.2 and Qt 5.6 while I like to use the current Qt LTS 5.9.x which is prebuild by Qt along with MinGW 5.3.0.
Whenever I link my program with MinGW I get the message:
g++ -Wl,-subsystem,windows -mthreads -o debug\PhotoCollector.exe debug/main.o debug/mainwindow.o debug/photocollection.o debug/photofile.o debug/photocollectionmodel.o debug/moc_mainwindow.o debug/moc_photocollection.o -lmingw32 -LC:\Qt_online\5.9.5\mingw53_32\lib C:\Qt_online\5.9.5\mingw53_32\lib\libqtmaind.a -LC:\utils\my_sql\my_sql\lib -LC:\utils\postgresql\pgsql\lib -lshell32 -LC:\Users\Michael\Downloads\Exif\exiv2-0.26-mingw.tar\exiv2-0.26-mingw\dist\mingw\lib -lexiv2.dll C:\Qt_online\5.9.5\mingw53_32\lib\libQt5Widgetsd.a C:\Qt_online\5.9.5\mingw53_32\lib\libQt5Guid.a C:\Qt_online\5.9.5\mingw53_32\lib\libQt5Cored.a debug/photocollectionmodel.o: In function `ZNK20PhotoCollectionModel4dataERK11QModelIndexi': C:\Users\Michael\Documents\Projects\PhotoCollector\PC_trunk\build-PhotoCollector-Desktop_Qt_5_9_5_MinGW_32bit-Debug/../PhotoCollector/photocollectionmodel.cpp:61: undefined reference to `Exiv2::ImageFactory::open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)' C:\Users\Michael\Documents\Projects\PhotoCollector\PC_trunk\build-PhotoCollector-Desktop_Qt_5_9_5_MinGW_32bit-Debug/../PhotoCollector/photocollectionmodel.cpp:64: undefined reference to `Exiv2::ExifData::operator[](std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' C:\Users\Michael\Documents\Projects\PhotoCollector\PC_trunk\build-PhotoCollector-Desktop_Qt_5_9_5_MinGW_32bit-Debug/../PhotoCollector/photocollectionmodel.cpp:64: undefined reference to `Exiv2::Value::toString[abi:cxx11]() const' collect2.exe: error: ld returned 1 exit status mingw32-make[1]: *** [debug\PhotoCollector.exe] Error 1
I tried different constallations in the Qt qmake .pro file but to no gain.
win32: LIBS += -L$$PWD/../../../../../Downloads/Exif/exiv2-0.26-mingw.tar/exiv2-0.26-mingw/dist/mingw/lib/ -lexiv2.dll INCLUDEPATH += $$PWD/../../../../../Downloads/Exif/exiv2-0.26-mingw.tar/exiv2-0.26-mingw/dist/mingw/include DEPENDPATH += $$PWD/../../../../../Downloads/Exif/exiv2-0.26-mingw.tar/exiv2-0.26-mingw/dist/mingw/include
and
win32: LIBS += -L$$PWD/../../../../../Downloads/Exif/exiv2-0.26-mingw.tar/exiv2-0.26-mingw/dist/mingw/lib/ -lexiv2 INCLUDEPATH += $$PWD/../../../../../Downloads/Exif/exiv2-0.26-mingw.tar/exiv2-0.26-mingw/dist/mingw/include DEPENDPATH += $$PWD/../../../../../Downloads/Exif/exiv2-0.26-mingw.tar/exiv2-0.26-mingw/dist/mingw/include
did not work, too.
Could someone be so nice and give me a hint, what I'm doing wrong.
Thanks,
Michael
Replies (5)
RE: Linking Problem with MinGW binary distribution and QT - Added by Robin Mills over 3 years ago
Michael
I have to admit to both a love of Qt and a dislike of MinGW.
I see you're getting undefined reference: Exiv2::Value::toString[abi:cxx11]() const and I'm wondering if building your application with C++11 when the library is built with C++98 is not possible. I've never thought about this combination. You can inspect entries in the library with the command:
471 -32- /usr/local/lib> nm -g --demangle libexiv2.dll.a | grep Exiv2::Value::toString 00000000 T Exiv2::Value::toString() const 00000000 T Exiv2::Value::toString(long) const 472 -32- /usr/local/lib>
I have investigated Exiv2+MinGW+Qt for users several times:
http://dev.exiv2.org/boards/3/topics/2705
http://dev.exiv2.org/issues/871
http://dev.exiv2.org/boards/3/topics/1304
There's an article about using MinGW+Exiv2
http://clanmills.com/exiv2/mingw.shtml
There is a sample application:
exiv2/contrib/cmake/mingw
RE: Linking Problem with MinGW binary distribution and QT - Added by Gilles Caulier over 3 years ago
More than one time i read weird reports about Qt + Exiv2 + Mingw from Exiv2 world...
How I can say... MinGW is certainly the best compiler that i know. And i know what i mean : I use it to package WHOLE digiKam installer for Windows, including last Qt5.10 + KF5 + All digiKam core 6.0.0 , and of course Exiv2 0.26.
But i don't use directly MinGw, but MXE cross compiler envirronement. It's a Jewel !
As you can see, MXE, as all that you need including Exiv2 package.
All source code are cross compiled under Linux. I don't use Windows to make the digiKam Windows installer. This take around 2 hours to buidl all from scratch on my host Linux computer (8 core, 32 Gb of RAM, SSD).
Remember : digiKam is more and less 1,5 M of lines of C++ code based on Qt5, and all compile, link, and run like a charm, under Windows 7, 8, and 10. You can debug under Windows using QtCreator at runtime.
https://www.openhub.net/p/digikam/analyses/latest/languages_summary
I cannot said better under MacOS (Macports) which is really a puzzle and a waste of time to maintain.
What's about MSVC : it's the most weird compiler and development env. that i need to use in my office where i manage around 250.000 line of code of C and C++ (Qt based). I don't want to use it about digiKam project, because it's a waste of time.
My scripts to compile and package digiKam for Windows under Linux using MXE :
https://github.com/KDE/digikam/tree/master/project/bundles/mxe
Best
Gilles Caulier
RE: Linking Problem with MinGW binary distribution and QT - Added by Michael Möllney over 3 years ago
Robin
sorry for the late reply.
Robin Mills wrote:
Michael
I have to admit to both a love of Qt and a dislike of MinGW.
I see you're getting undefined reference: Exiv2::Value::toString[abi:cxx11]() const and I'm wondering if building your application with C++11 when the library is built with C++98 is not possible. I've never thought about this combination. You can inspect entries in the library with the command: [...]
And thats probably it.
I found
Exiv2::ImageFactory::open(std::string const&, bool)
in the library using the nm tool you mentioned.
As far as I understood Qt 5.7 and newer need C++11 in the library so they probably bind agains the std::__cxx11::basic_string... so this may be it.
I think they still have a Qt 5.6 LTS (over 2 years old feature wise) and a toolchain with MinGW 4.9.2 around...
But maybe it is time to support the new C++11 abi in the precompiled versions.
Any chance to get a MinGW 5.3.x C++11 precompiled exiv2 download, maybe using the tools coming with the QtOnline installer?
That would be geat....
Kind regards,
Michael
RE: Linking Problem with MinGW binary distribution and QT - Added by Michael Möllney over 3 years ago
Hi Gilles
Gilles Caulier wrote:
More than one time i read weird reports about Qt + Exiv2 + Mingw from Exiv2 world...
How I can say... MinGW is certainly the best compiler that i know. And i know what i mean : I use it to package WHOLE digiKam installer for Windows, including last Qt5.10 + KF5 + All digiKam core 6.0.0 , and of course Exiv2 0.26.
But i don't use directly MinGw, but MXE cross compiler envirronement. It's a Jewel !
As you can see, MXE, as all that you need including Exiv2 package.
All source code are cross compiled under Linux. I don't use Windows to make the digiKam Windows installer. This take around 2 hours to buidl all from scratch on my host Linux computer (8 core, 32 Gb of RAM, SSD).
Remember : digiKam is more and less 1,5 M of lines of C++ code based on Qt5, and all compile, link, and run like a charm, under Windows 7, 8, and 10. You can debug under Windows using QtCreator at runtime.
https://www.openhub.net/p/digikam/analyses/latest/languages_summary
I cannot said better under MacOS (Macports) which is really a puzzle and a waste of time to maintain.
What's about MSVC : it's the most weird compiler and development env. that i need to use in my office where i manage around 250.000 line of code of C and C++ (Qt based). I don't want to use it about digiKam project, because it's a waste of time.
My scripts to compile and package digiKam for Windows under Linux using MXE :
https://github.com/KDE/digikam/tree/master/project/bundles/mxe
Best
Gilles Caulier
This is really interesting stuff.
At my company we cross-compile apps from linux to embedded linux and use VS to create windows GUI apps.
One gui in my team use MinGW to crosscompile his Windows Apps under linux. I will talk to him about how he manages to accomplish this. Maybe he even uses MXE but did tell me...
Thanks,
Michael
RE: Linking Problem with MinGW binary distribution and QT - Added by Robin Mills over 3 years ago
Michael
I built and distributed Exiv2 v0.26 MinGW binaries with C++98 and there is a simple test to compile code to link with Qt in the build. We will be adding support to build with C++11 in v0.27
We had an "Exiv2 Developer's Meeting" at my home in England last weekend. We discussed cross-compiling over lunch on Sunday. None of the three of us have ever done this. If you or your co-workers would like to work with me to get cross-compiling to work, I would appreciate your help.
I did try to install MXE on a VM running Kubuntu 16.04. After installing a couple of dependencies, the VM froze and would not reboot. I reverted to a snap-shot. I repeated the exercise with the same unsuccessful result.
Robin