How can I solve linkage error with QList in Qt6.2 - qt

while porting from Qt5 to Qt6 I get linkage errors while linking specific project in my solution.
Its happened only with QList types.
1>vNPI.debug_amd64.Dev_2019.AMD64.DFM2DataDef.lib(vNPI.debug_amd64.Dev_2019.AMD64.DFM2DataDef.dll) : error LNK2005: "public: __int64 __cdecl QList::count(void)const " (?count#?$QList#VQString####QEBA_JXZ) already defined in dfm2_chklistbuilder.obj
1>vNPI.debug_amd64.Dev_2019.AMD64.DFM2DataDef.lib(vNPI.debug_amd64.Dev_2019.AMD64.DFM2DataDef.dll) : error LNK2005: "public: bool __cdecl QList::isEmpty(void)const " (?isEmpty#?$QList#VQString####QEBA_NXZ) already defined in dfm2_chklistbuilder.obj
I tried to remove all include circles between two projects and cleaned environment from old Qt5 declarations. Also, I checked all static or partially declarations in both sides.

Related

Static linking Qt 5.7 with Visual Studio 2015

I did my search everywhere I could and I still have multiple problems with static compilling Qt under Windows (8.1, x64). I've tried a couple of articles describing how to do this, the last one (How to compile Qt 5 under Windows or Linux, 32 or 64 bit, static or dynamic on VS2010, VS2012, VS2013 or VS2015 Express or g++) was apparenty the closest to my case, but it's still not perfect. After applying changes pointed out here (Build static Qt project with Visual Studio 2015) I had errores:
Error LNK2019 unresolved external symbol gethostname referenced in function "public: static class QString __cdecl QSysInfo::machineHostName(void)" (?machineHostName#QSysInfo##SA?AVQString##XZ)
Error LNK2019 unresolved external symbol WSAStartup referenced in function "public: __cdecl QWindowsSockInit::QWindowsSockInit(void)" (??0QWindowsSockInit##QEAA#XZ)
Error LNK2019 unresolved external symbol WSACleanup referenced in function "public: __cdecl QWindowsSockInit::~QWindowsSockInit(void)" (??1QWindowsSockInit##QEAA#XZ)
Error LNK2019 unresolved external symbol WSAAsyncSelect referenced in function "public: void __cdecl QEventDispatcherWin32Private::doWsaAsyncSelect(int,long)" (?doWsaAsyncSelect#QEventDispatcherWin32Private##QEAAXHJ#Z)
which were gone after including ws2_32.dll from Windows SDK. Ok, I'm able to run my project inside my Visual Studio now, but I can't run the exe-file (which was the original point of static linking) because of the following error:
This application failed to start because it could not find or load the Qt platform plugin "windows" in "".
Can somebody please help me? I spent several days trying to figure this out.

Force order of linking libraries in Qt Creator

I'm trying to use a 3rd party driver from an app in Qt Creator. This app has to be included as a static library. It won't compile without the /MT flags. After much heartache, I've gotten it down to two linker errors:
msvcrtd.lib(ti_inst.obj):-1: error: LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info##AAE#ABV0##Z) already defined in LIBCMTD.lib(typinfo.obj)
msvcrtd.lib(ti_inst.obj):-1: error: LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info##AAEAAV0#ABV0##Z) already defined in LIBCMTD.lib(typinfo.obj)
I think this problem is described here. If that's the case, then I suppose I need to know how to force Qt Creator to link these system libraries in a specific order, when I haven't even included them explicitly in the .pro file in the first place. If someone could tell me how to do that, that'd be great. If, however, this isn't the same problem described on the MS page, an explanation of what I'm really doing wrong, would be even better.
Just to get this marked as answered, I'll quote kanders84152: "Never mind. I was linking against the wrong msvc library. Supposed to use msvcmrt.lib and not msvcurt.lib nor msvcprt.lib. It seems to work now. Thanks, all."

Linker errors when using OpenGL in Qt

I am trying to use OpenGL with Qt.
I was following this example: http://qt-project.org/doc/qt-5.0/qtgui/openglwindow.html using Qt 5 build for msvc2012. In the end I am getting the following errors:
error LNK2019: unresolved external symbol _imp_glClear#4 referenced in function "public: virtual void __thiscall OpenGLWindow::render(void)" (?render#OpenGLWindow##UAEXXZ) D:\Documents\Code\Qt Projects\qttest2\qttest2\openglwindow.obj qttest2
error LNK2001: unresolved external symbol _imp_glClear#4 D:\Documents\Code\Qt Projects\qttest2\qttest2\trianglewindow.obj qttest2
error LNK2019: unresolved external symbol _imp_glDrawArrays#12 referenced in function "public: virtual void __thiscall TriangleWindow::render(void)" (?render#TriangleWindow##UAEXXZ) D:\Documents\Code\Qt Projects\qttest2\qttest2\trianglewindow.obj qttest2
error LNK2019: unresolved external symbol _imp_glViewport#16 referenced in function "public: virtual void __thiscall TriangleWindow::render(void)" (?render#TriangleWindow##UAEXXZ) D:\Documents\Code\Qt Projects\qttest2\qttest2\trianglewindow.obj qttest2
error LNK1120: 3 unresolved externals D:\Documents\Code\Qt Projects\qttest2\Win32\Debug\qttest2.exe qttest2
I can see that it has to do with the linking of OpenGL functions but I don't have much knowledge about linking.
I get the errors even if I copy the source code in from the OpenGLWindow example.
You must add opengl32.lib to the list of linked libraries. Adding the OpenGL module in the QtCreator .pro file should do the trick
QT += opengl
Have you added the OpenGL module in your pro file like this:
QT += opengl
If you use Qt 5, then add next lib in you project file (*.pro)
LIBS += -LD:\Qt\5.5\mingw492_32\lib\libQt5OpenGL.a -lopengl32
D:\Qt\5.5\mingw492_32\lib\libQt5OpenGL.a is path.
In linux environment [mesa] library installation can resolve the issue.
[lib32-mesa, an open-source implementation of the OpenGL specification]
[pacman -S mesa ] *Arch Linux
[apt-get install mesa] *ubuntu/Mint/Raspbian

Running project with Qt includes in Visual Studio express 2008

I'm still a newbie at this so please bear with me :)
I just got a vs 2008 project that has a few qt includes, namely qtGUI. Now I downloaded the open source pre-built libraries (version 4.8.3) from the qt-project.org site. I've added the include and lib directories under vs2008, but my project still won't compile. I'm getting a few LNK 2001 unresolved external symbol errors. Could someone tell me what I'm missing here?
The specific errors:
treeview.obj : error LNK2001: unresolved external symbol "public:static struct QMetaObject const cQtTreeWidgetFilter::staticMetaObject"(?staticMetaObject#cQtTreeWidgetFilter##2UQMetaObject##B)
treeview.obj : error LNK2001: unresolved external symbol "public:virtual struct QMetaObject const * __thiscall cQtTreeWidgetFilter::metaObject(void)const " (?metaObject#cQtTreeWidgetFilter##UBEPBUQMetaObject##XZ)
treeview.obj : error LNK2001: unresolved external symbol "public:virtual void * __thiscall cQtTreeWidgetFilter::qt_metacast(char const *)" (?qt_metacast#cQtTreeWidgetFilter##UAEPAXPBD#Z)
treeview.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall cQtTreeWidgetFilter::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall#cQtTreeWidgetFilter##UAEHW4Call#QMetaObject##HPAPAX#Z)
After days of trouble I found a reference in the sdk suggesting that I should downgrade qt to a previous version. I went and downloaded 4.6.2 and now it generates the moc file and compiles without error.
Thanks for the help dreschjerm.

using QuaZip on Windows with VS2008

I'm using QT4.7.3, VS2008 and trying to add QuaZip library.
I got QuaZip, Zlib and compile it, and then I can make "quazip.lib" file.
I added quazip.lib to "Project property->Configuration Properties->Linker->Input->Additional Dependencies" and include pathes.
I wrote the source code as below.
#include "Updater.h"
#include "quazip.h"
Updater::Updater(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
QuaZip *qZip = new QuaZip();
}
but, here, I stuck in problem.
Error message is shown as below.
Updater.obj : error LNK2019: unresolved external symbol
"__declspec(dllimport) public: _thiscall QuaZip::QuaZip(void)"
(_imp_??0QuaZip##QAE#XZ) referenced in function "public: __thiscall
Updater::Updater(class QWidget *,class QFlags)"
(??0Updater##QAE#PAVQWidget##V?$QFlags#W4WindowType#Qt#####Z)
1>.\updater.exe : fatal error LNK1120: 1 unresolved externals
I know this error occurs when declaration exists but definition doesn't exists.
As a result of find QuaZip constructor, I found as below.
QuaZip::QuaZip():
p(new QuaZipPrivate(this))
{
}
How can I make it correct?
Thank you for any comment.
I have found the following message in Quazip's README file:
If you want to include QuaZIP sources directly into your project or if
you want to use QuaZIP compiled as a static library using
"qmake CONFIG+=statliclib", you have to define the QUAZIP_STATIC macro,
otherwise you're likely to run into problems as QuaZIP symbols will be
marked as dllimported.
Maybe that will help you.

Resources