Linking error because of different versions MSVC and Qt libraries - qt

I am having trouble with compiling a Qt project using the MSVC 2012 compiler. I downloaded Qt first, then realised I didn't have a proper compiler yet, and then downloaded Microsoft Visual Studio Express 2012 and its msvc compilers.
However, whenever I try to compile something in Qt Creator, it gives the following error:
qtmain.lib(qtmain_win.obj):-1: LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match with value '1700' in glwidget.obj
So my understanding of what this means is that my Qt libraries are of a different (older) version than my msvc compiler. But I am not sure how to fix it, or how to get other/newer libraries. Some googling told me that the following code added to the Qt .pro file should solve things:
QMAKE_COMPILER_DEFINES += _MSC_VER=1700 WIN32
But that didn't have any effect. Also, using '1600' instead of '1700' didn't help. Any ideas on what will?
I am working on a 32-bit Windows 7 system, if that's any help, and I'm using Qt 5.0.0.

You need binaries compiled for the Visual Studio 2012. Since there is no official (or unofficial) precompiled binaries available, you need to compile them by yourself.
This should not be complicated process, but it can be hard and frustrating for beginners to do to it, so I would suggest you to follow already given advice and to download VS2010 (afterall, it will take less time to download and install it than to compile Qt from source).

You have to use MSVC 2010, because the libraries are built using it. Try Visual C++ 2010 Express.

Related

Can't make Qt Creator Work

I've downloaded and installed Qt Creator from its online installer and the latest version but when i try to create a Qt Console Application i get the following error. I haven't touched options. The picture is an error from when i tried to open a file from my professor but i get the same error when i try to create a new one. It could be pretty simple but its the 1st time im using this program as a student and have no idea whats going on. Thanks in regards for your timeenter image description here
If you are using Qt Creator with MSVC Compiler (Visual Studio), you need to also download the Visual Studio Compiler. Qt for MSVC doesn't come with a compiler.
It seems that you are trying to compile with VS 2017. You can Download Visual Studio 2017 from: https://www.visualstudio.com/es/downloads/
Express is free, the other two are paid, but don't download VS Code, it's for another purpose.
Alternatively, you can download only the compiler from: http://landinghub.visualstudio.com/visual-cpp-build-tools It's ligther but you don't get the IDE.
Also, for debugging, if you are on x86 or x64, download Windows CDB from: https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-download-tools
After you install this, you can reboot Qt and then it will show it has the appropiate compiler and debugger, like this (note that I use VS 2013):
There is another option if you don't want to download or use Visual Studio. Go to the Qt Maintenance Tool (uninstaller), Add or remove components, then install MinGW binaries of your favorite Qt Version, like this:
MinGW is free and it comes bundled with Qt, so you can build and run (and debug!) right away.

Building a Qt 4.8 application on Visual Studio

I'm working on building Open-Sankoré project (https://github.com/Sankore/Sankore-3.1) which is made by Qt 4.8-msvc compiler..
But, visual studio 2015 only works with Qt5 and doesn't accept Qt4 packages directly..
So my question is whether there's any walk-around that could be done to make visual studio build Qt 4.8 projects ?
You would have to compile Qt4.8 from source if you want to use Visual Studio 2015 with that exact version (4.8). There is no official release of Qt4.8 that was built using msvc2015.
If you are really tied to the Qt4.8 version, my suggestion would be to download and install lower version of Visual Studio and the corresponding compiler, e.g., msvc2008.
Although, before doing so, I would confirm if the project you are trying to build is really bounded to the Qt4.8 version. It might work as expected with the higher Qt version; or with some added modifications.
Sankore is a bit of a mess and is abandonware, but I've forked it and ported it to Qt 5 and it was not a big job. The build system is still iffy and I haven't tested it on anything but OS X.
It currently builds and functions from a stand-alone top project under Qt Creator, i.e. the dependencies (other than Phonon) get built alongside the rest of it.
Phonon builds under Qt 5 - see phonon4qt5. It needs cmake and may be a bit iffy. Only a few classes need phonon in Sankore, and thus require porting over to Qt Multimedia. That should be the first order of business if you wish to work on the code.
Check out the qt5-compat branch from these repositories:
https://github.com/KubaO/Sankore-3.1
https://github.com/KubaO/Sankore-ThirdParty
I'm accepting pull requests, of course.

How do I determine the cause of Qt's "*** is not a valid Qt plugin" error?

When I print the value of errorString from my QPluginLoader object, I get this:
The file 'C:/pyprojects/test/qsqlpsqld4.dll' is not a valid Qt plugin.
I would like to avoid some days worth of doing the time consuming "guess-and-check" methodology that my current internet searches reveal (so far none of them seem relevant anyways).
Is there a way for me to get the Qt library itself to tell me why it is refusing to load this plugin?
I don't want to guess; I want to know.
Context:
I am on Windows 7 running Qt 4.8.5 (32-bit, MinGW) and the qsqlpsqld4.dll file is also 32-bit and compiled with MinGW.
I am using PySide to interact with Qt.
It sounds like PySide wants the non-debug version of the library.
When you are in debug mode, it references libraries that end in d.dll or d4.dll. Try grabbing the plugin that does not have the d in the end of the dll name, and put it in the same spot.
I recently went through the throws of compiling one of the mysql qt plugins for 4.8.4 for visual studio 2010 and came out the victor.
Let me know if making that change fixes it or not. :)
Hope that helps.
PySide does not support MinGW. Official PySide distributions are compiled with Visual C++. You need to recompile your plugin with compatible Visual C++ version. By default PySide for Python 2.6, 2.7 and 3.2 is compiled with VC++ 2008. PySide for Python 3.3 is compiled with VC++ 2010 compiler.

Qt5 libs compiled with vc110 for vs2012?

I wanted to ask, are there qt5 pre-compiled versions for Visual Studio 2012. The add-in runs fine with me, but I can not start the program, because the appropriate *.libs missing.
Has someone happened to be there a compiled version to download or a configuration to translate the sources?
greetz, Tobias.
You can find some already compiled vs2012 Qt5 libraries in here.
But those are for x64 platform only...
(for example http://releases.qt-project.org/digia/5.0.2/latest_successful/qt-windows-opensource-5.0.2-msvc2012_64-x64-offline-2013-03-14-456.exe)
For x86 you will need to compile Qt by yourself, and that's a bit of pain (especially if you need WebKit included) + takes really long compilation time.
When compiling you can try and follow this:
http://qt-project.org/wiki/Building_Qt_5_from_Git
Plus, found some interesting russian guy blog site that may be worth checking out: http://habrahabr.ru/post/168671/

How to force Qt Creator to use MinGW instead of Visual Studio

We're trying to compile a project with MinGW on the machine that has both MinGW (with Qt) and Visual Studio installed. Unfortunately, Qt creator prefers MSVS by default, and doesn't see it's very own MinGW (screenshot). Sadly, this results in a lot of obscure errors, because application was written and debugged with MinGW. Is there way to make Qt Creator to use MinGW without killing MSVS?
While installing, choose custom type of installation. Selected libraries for needed compilers in QtSDK->Development Tools->Desktop Qt->Qt-. Screenshot:
Have you made sure your Qt sdk is installed with its MinGW? You can use the Qt maintainance app to make sure its MinGW engine is installed.
Where are those libraries from? Did you compile the SDK yourself? Or did you downloded the libraries?
Try to see what is in the mkspecs directory. There should be a link named 'default'. That links to the specification which is being used. I suppose it is pointing to win32-msvc2008. You can change that but if it is pointing to that specification it means that the Qt libraries have been compiled with that specification (unless it was changed afterwards), which means you cannot use those with MinGW. You should compile the libraries with the correct specification or download the correct package (MinGW version).

Resources