Qt and static lib files - how to compile - c++

I need to build a Qt5 64 bit program which links to static .lib libraries (compiled with /MT). I tried changing the lines below from MD to MT:
QMAKE_CFLAGS_RELEASE = -O2 -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
QMAKE_CFLAGS_DEBUG = -Zi –MTd
in the file D:\Qt\Qt5.0.0src\qtbase\mkspecs\win32-msvc2010\qmake.conf
and recompiling it with
configure -prefix %CD%\qtbase -debug-and-release -opensource -platform win32-msvc2010 -opengl desktop
and then nmaking it, but it failed with:
XPathGrammar.cpp
Generating Code...
lib /NOLOGO /OUT:release\WebCore.lib #C:\Users\Paul\AppData\Local\Temp\WebCore.lib.4480.3319717.jom
LINK : fatal error LNK1181: cannot open input file '.obj\release_shared\SettingsMacros.obj'
jom: D:\Qt\Qt5.0.0src\qtwebkit\Source\WebCore\Makefile.WebCore.Target.Release [release\WebCore.lib] Error 1181
jom: D:\Qt\Qt5.0.0src\qtwebkit\Source\WebCore\Makefile.WebCore.Target [release] Error 2
jom: D:\Qt\Qt5.0.0src\qtwebkit\Source\WebCore\Makefile.WebCore [sub-Target-pri-make_first-ordered] Error 2
jom: D:\Qt\Qt5.0.0src\qtwebkit\Makefile [sub-Source-WebCore-WebCore-pro-make_first-ordered] Error 2
jom: D:\Qt\Qt5.0.0src\Makefile [module-qtwebkit-make_first] Error 2
It seems that the "SettingsMacros.obj" file doesn't get generated. Why is that?
Do I need to include "-static" in the configure string? I know that Qt doesn't get along with /MT but my project needs it otherwise I would not be able to link those .lib files

yes, you do need to add -static. Worked for me.

Related

Qt Can't find std library for a project

I have a project in Qt which was working. Then once I shut down creator, opened it back up and rebuilt the project, Qt now says it can't find any of the std library headers. The error message is:
D:\Devlibs\Qt\5.7\msvc2015_64\include\QtCore\qglobal.h:45: error:
C1083: Cannot open include file: 'cstddef': No such file or directory
(Along with all the other std library headers I used)
I am building with vs 2015, and it would seem like Qt is not setting up the VS environment, but here's the thing, my other projects (in the same directory) build just fine. I have tried deleting the .pro files and the build files, re configuring the project, as well as reinstalling Qt, and running Qt from the command line. All to no avail.
I would just like to know what/where in the Qt environment is VS setup and what could cause only one project to behave this way? I assumed it would be in the Makefile, but I couldn't see anything when I went through it.
The entire compile output is:
10:13:03: Running steps for project QARD_Viewer...
10:13:03: Configuration unchanged, skipping qmake step.
10:13:03: Starting: "D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\nmake.exe"
"D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\nmake.exe" -f Makefile.Release
cl -c -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zc:throwingNew -O2 -MD -GR -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -EHsc -DUNICODE -DWIN32 -DWIN64 -DQWT_DLL -DQT_NO_DEBUG -DQT_WEBENGINE_LIB -DQT_WEBENGINEWIDGETS_LIB -DQT_WEBENGINECORE_LIB -DQT_QUICK_LIB -DQT_SVG_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_WEBCHANNEL_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DNDEBUG -I..\QARD_Viewer -I. -I"D:/Users/JSendall/Documents/PCL/GUI/QARD_Viewer/../PXGFtoFile/AARD Backup" -ID:/Users/JSendall/Documents/PCL/GUI/QARD_Viewer/../SIMD_vectors/SIMD_vectors -I"D:/Users/JSendall/Documents/PCL/GUI/QARD_Viewer/../PCL Proc Server/Common files" -ID:\Devlibs\boost_1_62_0 -ID:\Devlibs\Qwt-6.1.3\include -I..\..\Deployment\Code\PXGF_socket\PXGF_socket -I..\..\Deployment\Code\QardDetector\cfarLib -I..\..\Deployment\Code\coordHandling\coordHandling -I"..\..\Deployment\Code\PXGFtoFile\AARD Backup" -I"..\..\Deployment\Code\PCL Proc Server\Common files" -I..\..\Deployment\Code\SIMD_vectors\SIMD_vectors -I..\..\Deployment\Code\pxgf_rpk_client\pxgf_rpk_client -I..\..\Deployment\Code\QardDetector\QardDetector -ID:\Devlibs\Qt\5.7\msvc2015_64\include -ID:\Devlibs\Qt\5.7\msvc2015_64\include\QtWebEngine -ID:\Devlibs\Qt\5.7\msvc2015_64\include\QtWebEngineWidgets -ID:\Devlibs\Qt\5.7\msvc2015_64\include\QtWebEngineCore -ID:\Devlibs\Qt\5.7\msvc2015_64\include\QtQuick -ID:\Devlibs\Qt\5.7\msvc2015_64\include\QtSvg -ID:\Devlibs\Qt\5.7\msvc2015_64\include\QtWidgets -ID:\Devlibs\Qt\5.7\msvc2015_64\include\QtGui -ID:\Devlibs\Qt\5.7\msvc2015_64\include\QtANGLE -ID:\Devlibs\Qt\5.7\msvc2015_64\include\QtWebChannel -ID:\Devlibs\Qt\5.7\msvc2015_64\include\QtQml -ID:\Devlibs\Qt\5.7\msvc2015_64\include\QtNetwork -ID:\Devlibs\Qt\5.7\msvc2015_64\include\QtCore -Irelease -I. -ID:\Devlibs\Qt\5.7\msvc2015_64\mkspecs\win32-msvc2015 -Forelease\ #C:\Users\JSendell\AppData\Local\Temp\nm6F02.tmp
main.cpp
D:\Devlibs\Qt\5.7\msvc2015_64\include\QtCore/qglobal.h(45): fatal error C1083: Cannot open include file: 'cstddef': No such file or directory
mainwindow.cpp
D:\Devlibs\Qt\5.7\msvc2015_64\include\QtCore/qglobal.h(45): fatal error C1083: Cannot open include file: 'cstddef': No such file or directory
ardplot_t.cpp
D:\Devlibs\Qt\5.7\msvc2015_64\include\QtCore\qglobal.h(45): fatal error C1083: Cannot open include file: 'cstddef': No such file or directory
qread.cpp
..\..\Deployment\Code\PCL Proc Server\Common files\QARDHeader.h(3): fatal error C1083: Cannot open include file: 'cstdint': No such file or directory
cfarplotter.cpp
D:\Devlibs\Qt\5.7\msvc2015_64\include\QtCore\qglobal.h(45): fatal error C1083: Cannot open include file: 'cstddef': No such file or directory
detectiondisplay.cpp
D:\Devlibs\Qt\5.7\msvc2015_64\include\QtCore/qglobal.h(45): fatal error C1083: Cannot open include file: 'cstddef': No such file or directory
geocode_data_manager.cpp
D:\Devlibs\Qt\5.7\msvc2015_64\include\QtCore/qglobal.h(45): fatal error C1083: Cannot open include file: 'cstddef': No such file or directory
cacfdetector.cpp
..\..\Deployment\Code\QardDetector\cfarLib\caCfarDetector.h(2): fatal error C1083: Cannot open include file: 'numeric': No such file or directory
label_connected.cpp
d:\users\jsendall\documents\pcl\gui\qard_viewer\label_connected.h(3): fatal error C1083: Cannot open include file: 'vector': No such file or directory
Generating Code...
NMAKE : fatal error U1077: '"D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\nmake.exe"' : return code '0x2'
Stop.
10:13:04: The process "D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\nmake.exe" exited with code 2.
Error while building/deploying project QARD_Viewer (kit: Desktop Qt 5.7.0 MSVC2015_64bit)
When executing step "Make"
10:13:04: Elapsed time: 00:01.

Setting CUDA_NVCC_FLAGS using CMake

I am trying to compile a CUDA project using CMake on Windows. I am not familiar with make or CMake and I have done some reading over the past few days, but I am still not able to figure this out. I get the following error message:
Chri#Riemann-PC /cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64
$ make
[ 1%] Built target lapacktest
[ 1%] Building NVCC (Device) object CMakeFiles/magma.dir/magmablas/magma_generated_zherk_batched_core.cu.o
nvcc fatal : nvcc cannot find a supported version of Microsoft Visual Studio. Only the versions 2010, 2012, and 2013 are supported
CMake Error at magma_generated_zherk_batched_core.cu.o.cmake:207 (message):
Error generating
/cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas/./magma_generated_zherk_batched_core.cu.o
CMakeFiles/magma.dir/build.make:2058: recipe for target 'CMakeFiles/magma.dir/magmablas/magma_generated_zherk_batched_core.cu.o' failed
make[2]: *** [CMakeFiles/magma.dir/magmablas/magma_generated_zherk_batched_core.cu.o] Error 1
CMakeFiles/Makefile2:105: recipe for target 'CMakeFiles/magma.dir/all' failed
make[1]: *** [CMakeFiles/magma.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Using the make VERBOSE=1 command, I get the following error:
cd /cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas && /usr/bin/cmake.exe -D verbose:BOOL=1 -D build_configuration:STRING= -D generated_file:STRING=/cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas/./magma_generated_zherk_batched_core.cu.o -D generated_cubin_file:STRING=/cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas/./magma_generated_zherk_batched_core.cu.o.cubin.txt -P /cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas/magma_generated_zherk_batched_core.cu.o.cmake
-- Removing /cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas/./magma_generated_zherk_batched_core.cu.o
/usr/bin/cmake.exe -E remove /cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas/./magma_generated_zherk_batched_core.cu.o
-- Generating dependency file: /cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas/magma_generated_zherk_batched_core.cu.o.NVCC-depend
"/cygdrive/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5/bin/nvcc.exe" -M -D__CUDACC__ /cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/magmablas/zherk_batched_core.cu -o /cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas/magma_generated_zherk_batched_core.cu.o.NVCC-depend -ccbin /usr/bin/gcc.exe -m64 -Xcompiler ,\"-fopenmp\",\"-Wall\",\"-Wno-unused-function\",\"-g\" -DHAVE_CUBLAS -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_35,code=compute_35 -DNVCC "-I/cygdrive/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5/include" "-I/cygdrive/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5/include" -I/cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/include -I/cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/control
nvcc fatal : nvcc cannot find a supported version of Microsoft Visual Studio. Only the versions 2010, 2012, and 2013 are supported
It is still using the gcc compiler (-ccbin /usr/bin/gcc.exe).
I went into the file: C:\Apps\ThirdParty\cygwin64\usr\share\cmake-3.3.2\Modules\FindCUDA.cmake and added the following lines:
set(VS_DIR "C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\bin")
message(${VS_DIR})
set(CUDA_NVCC_FLAGS "-ccbin ${VS_DIR}" CACHE STRING "Semi-colon delimit multiple arguments.")
I also added the following line to the nvcc.profile file:
CUDA_NVCC_FLAGS += -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin";
Still no luck. I have spent a few days trying to fix this. I am grateful for any help in this matter.
The option to set the host compiler in FindCUDA is CUDA_HOST_COMPILER, see the FindCUDA documentation.
Try
set(CUDA_HOST_COMPILER "<path to compiler executable>")
or alternatively set it when invoking the cmake command
cmake .. -DCUDA_HOST_COMPILER=<path to compiler executable>
I guess the CUDA_HOST_COMPILER option overrides the ccbin settings of CUDA_NVCC_FLAGS. For other options you can use CUDA_NVCC_FLAGS in the way you tried. (Thus, the title is misleading. It is not a problem of how to set CUDA_NVCC_FLAGS.)
I use this often on Linux, however I don't have a Windows environment to test it there.

Error when compiling the driver for MYSQL for QT

I am trying to build the MYSQL driver for QT so I can include it in my projects. I am using QT 5.5.1, MYSQL 5.7, and MinGW 4.9.2 32 bit. I open the ".pro" file from the driver source code in the QT Creator and add INCLUDEPATH += C:/Program Files (x86)/MySQL/MySQL Server 5.7/include and
QMAKE_LIBDIR += C:/Program Files (x86)/MySQL/MySQL Server 5.7/lib/libmysql.lib to the project file and attempt to build. I get one error in response.
This is the error:
error: mysql.append(\lib\libmysql.lib): No such file or directory
This is the compiler output:
g++ -Wl,-s -shared -Wl,-subsystem,windows
-Wl,--out-implib,C:\Qt\5.5\Src\qtbase\plugins\sqldrivers\libqsqlmysql.a
-o ........\plugins\sqldrivers\qsqlmysql.dll .obj/release/main.o .obj/release/qsql_mysql.o .obj/release/moc_qsql_mysql_p.o
-LC:\Program -LFiles -L(x86)\MySQL\MySQL -LServer -L5.7\lib\libmysql.lib mysql.append(\lib\libmysql.lib) -Ls:/lib -LC:/Qt/5.5/mingw492_32/lib -lQt5Sql -lQt5Core .obj\release\qsqlmysql_resource_res.o g++: error:
mysql.append(\lib\libmysql.lib): No such file or directory
Makefile.Release:81: recipe for target
'........\plugins\sqldrivers\qsqlmysql.dll' failed mingw32-make[1]:
* [........\plugins\sqldrivers\qsqlmysql.dll] Error 1 mingw32-make[1]: Leaving directory
'C:/Qt/5.5/Src/qtbase/src/plugins/sqldrivers/mysql' mingw32-make: *
[release-all] Error 2 makefile:38: recipe for target 'release-all'
failed 11:55:06: The process
"C:\Qt\Tools\mingw492_32\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project mysql (kit: Desktop Qt 5.5.1
MinGW 32bit) When executing step "Make"
What can I do to stop this error?

Unrecognized Command Line Option '-WI'

I'm trying to set up my Qt for college and I'm running into some issues. I'm running Windows 8, and I'm not sure which version of Qt or QtCreator but not the latest - we were given the version installer so we must use this one, although I did install the latest MinGW myself before the QtCreator setup.
I tried some demo code in QtCreator and I got the error "Unrecognized Command Line Option "-WI" when I try run the following code.
#include <QtCore/QCoreApplication>
#include <QtGui/QMessageBox>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QMessageBox msgBox;
msgBox.setText("This is some text.");
msgBox.exec();
return a.exec();
}
I need to do my assignment and I'm not sure how I can do it when I'm getting all of these strange errors.
Any help would be appreciated.
Thanks in advance!
* EDIT *
This is the error output that I can find in QtCreator during the build process.
Running build steps for project TestProject...
Configuration unchanged, skipping qmake step.
Starting: "C:/MinGW/bin/mingw32-make.exe" -w
mingw32-make: Entering directory 'C:/Users/Nick/Documents/Qt Projects/TestProject-build-desktop'
C:/MinGW/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'C:/Users/Nick/Documents/Qt Projects/TestProject-build-desktop'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\TestProject.exe debug/main.o -L"c:\Qt\2010.04\qt\lib" -lQtCored4
Makefile.Debug:73: recipe for target 'debug\TestProject.exe' failed
mingw32-make[1]: Leaving directory 'C:/Users/Nick/Documents/Qt Projects/TestProject-build-desktop'
Makefile:34: recipe for target 'debug' failed
mingw32-make: Leaving directory 'C:/Users/Nick/Documents/Qt Projects/TestProject-build-desktop'
g++: error: unrecognized command line option '-Wl'
mingw32-make[1]: *** [debug\TestProject.exe] Error 1
mingw32-make: *** [debug] Error 2
The process "C:/MinGW/bin/mingw32-make.exe" exited with code %2.
Error while building project TestProject (target: Desktop)
When executing build step 'Make'
Here are the contents of the .pro file generated by QtCreator :
QT += core
QT -= gui
TARGET = TestProject
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
As Mats says the problem is the extra -Wl in the command line.
This is due to a bug in the QT conf files, and thankfully this can be fixed "permanently" (locally).
You need to edit one (possibly both) of these files (often in C:\Qt\2010.02\qt\mkspecs):
mkspecs\default\qmake.conf
mkspecs\win32-g++\qmake.conf
changing this:
QMAKE_LFLAGS = -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads -Wl
to this:
QMAKE_LFLAGS = -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
QMAKE_LFLAGS_EXCEPTIONS_ON = -mthreads
because somehow the -Wl, from the start of the first line is wrongly on the end of the second line.
After this edit, if you clean and then rebuild your project you will no longer see the error.
Notes:
this same bug causes this issue too, so thanks to leemes for his answer there)
it is fixed in Qt since version 4.7 I believe
The problem is clearly:
g++ -enable-stdcall-fixup -Wl,-enable-auto-import
-Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\TestProject.exe debug/main.o -L"c:\Qt\2010.04\qt\lib" -lQtCored4
I'm not sure exaclty how this is compiled, but to me it looks like a makefile with -Wl${somestuff} and for some reason ${somestuff} is not defined. Either that, or there is a spurious -Wl in the commendline for the link command, but that seems less likely.

Compiler error when building Qt

I am trying to build Qt myself. I checked out everything and want to run configure now. The Visual Studio 2013 compiler is in PATH but I get this error
C:\Users\Philipp\Desktop\Qt>configure -developer-build -opensource -nomake examp
les -nomake tests -opengl desktop
+ cd qtbase
+ C:\Users\Philipp\Desktop\Qt\qtbase\configure.bat -top-level -developer-build -
opensource -nomake examples -nomake tests -opengl desktop
Please wait while bootstrapping configure ...
<srcbase> = C:/Users/Philipp/Desktop/Qt/qtbase
<outbase> = C:/Users/Philipp/Desktop/Qt/qtbase
Microsoft (R) Program Maintenance Utility Version 12.00.21005.1
Copyright (C) Microsoft Corporation. All rights reserved.
cl -c -Yc -nologo -Zm200 -Zc:wchar_t -MT -W3 -GR -EHsc -w34100 -w34189
-DUNICODE -DQT_NO_CODECS -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_LITE_COMPO
NENT -DQT_NO_COMPRESS -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -D_CRT
_SECURE_NO_DEPRECATE -DQT_BOOTSTRAPPED -DQT_BUILD_CONFIGURE -DCOMMERCIAL_VERSION
-I"..\..\include" -I"..\..\include\QtCore" -I"..\..\include\QtCore\5.2.0" -I"..
\..\include\QtCore\5.2.0\QtCore" -I"C:\Users\Philipp\Desktop\Qt\qtbase\tools\sha
red" -I"C:\Users\Philipp\Desktop\Qt\qtbase\mkspecs\win32-msvc2008" -Fpconfigure_
pch.pch -Foconfigure_pch.obj -TP C:\Users\Philipp\Desktop\Qt\qtbase\tools\config
ure\configure_pch.h
configure_pch.h
c:\users\philipp\desktop\qt\qtbase\include\qtcore\../../src/corelib/global/qglob
al.h(46) : fatal error C1083: Cannot open include file: 'stddef.h': No such file
or directory
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0
\VC\bin\cl.EXE"' : return code '0x2'
Stop.
Does anyone know how to solve this?
Compiler itself in the PATH variable is not enough, it needs to know where include files and libraries are located.
Check vc++ has PATH variables it uses defined (at least both INCLUDE and LIBPATH).
If not you have two options:
Run configure from Developer Command Prompt (you can find it in the Visual Studio Tools program group).
From any command prompt window run VcVars32.bat batch file (or VsVars32.bat) located in Common7\Tools folder under VS installation directory.