PDA

View Full Version : Can't compile with MSVC



qzmich
3rd May 2016, 10:40
I download and install qt-opensource-windows-x86-msvc2010-5.5.1.exe, create new project (Qt Widgets application), build it (no changes to the project) and get this:

11921

What is the problem and how to solve it?

Windows 7, MSVC 2010 Professional is installed.

d_stranz
3rd May 2016, 20:45
Make sure that in your project properties, "C++ -> Language -> Treat wchar_t as Built-in Type" is set to True. The default for new projects in VS 2008 (and I guess 2010) is to set that to False. Qt5 is built with the flag set to True. The mismatch causes all these obscure errors that you see.

qzmich
3rd May 2016, 23:51
"Treat wchar_t as Built-in Type" is set to "Yes".
But my problem is that Qt Creator can't compile with MSVC2010 compiler. Maybe there is some place where some similar option can be set?

d_stranz
4th May 2016, 17:54
I suggest you fire up your browser and paste the "C2906..." (the first) error text into a Google search box and see what the links say about where this error comes from. The rest of the errors are probably just as a result of the first one, and if you fix that they will go away.


But my problem is that Qt Creator can't compile with MSVC2010 compiler.

Qt Creator can compile with any C++ compiler you configure as a "kit" - I use it on Windows with VS 2008, VS 2013, VS 2015, Android gcc, and minGW (see the screenshot). If you are trying to use Qt Creator to compile your project (and not the Visual Studio IDE), then you need to be sure that you are using the same compiler options in Qt Creator that you have set in the VS IDE. You do this in the .pro file (http://doc.qt.io/qt-5/qmake-variable-reference.html#qmake-cxxflags) for your project.

11922

qzmich
4th May 2016, 23:29
The most important compiler options seem to be the same, but why are they "unknown"?

E:\Qt3\Qt5.5.1\Tools\QtCreator\bin\jom.exe -f Makefile.Release
cl -c -nologo -Zc:wchar_t -O2 -MD -GR -W3 -w34100 -w34189 -w44996 -EHsc -DUNICODE -DWIN32 -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -I..\eeee -I. -IE:\Qt3\Qt5.5.1\5.5\msvc2010\include -IE:\Qt3\Qt5.5.1\5.5\msvc2010\include\QtWidgets -IE:\Qt3\Qt5.5.1\5.5\msvc2010\include\QtGui -IE:\Qt3\Qt5.5.1\5.5\msvc2010\include\QtANGLE -IE:\Qt3\Qt5.5.1\5.5\msvc2010\include\QtCore -Irelease -I. -IE:\Qt3\Qt5.5.1\5.5\msvc2010\mkspecs\win32-msvc2010 -Forelease\ @C:\Users\qzmich\AppData\Local\Temp\main.obj.6428. 16.jom
main.cpp
Command line warning D4002 : ignoring unknown option '-Zc'
Command line warning D4002 : ignoring unknown option '-Z:'
Command line warning D4002 : ignoring unknown option '-Zw'
Command line warning D4002 : ignoring unknown option '-Zc'
Command line warning D4002 : ignoring unknown option '-Zh'
Command line warning D4002 : ignoring unknown option '-Zr'
Command line warning D4002 : ignoring unknown option '-Z_'
Command line warning D4002 : ignoring unknown option '-Zt'
Command line warning D4002 : ignoring unknown option '-w34100'
Command line warning D4002 : ignoring unknown option '-w34189'
Command line warning D4002 : ignoring unknown option '-w44996'

d_stranz
5th May 2016, 17:54
No idea. It looks like cl is somehow taking apart the "-Zc:wchar_t" option character by character and trying to interpret each one as a separate option. They are only warnings, though. Does it compile?

qzmich
5th May 2016, 20:39
No, it doesn't. More than 100 errors, compiler stops.