I work on the CMake-based Qt project in MS Visual Studio. When I try to evaluate any method of a Qt object, I receive the error:
Function <blablabla> has no address, possibly due to compiler optimizations.
Image: QuickWatch evaluation error
I build in the DEBUG mode; I see the compiler invoked with no optimizations:
cl.exe ... /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1
Also, I checked the PDBs are loaded:
Image: VS Modules Window with PDBs loaded
But nothing of this helps: all the objects evaluated well, but Qt's - are not.
Is there anything that will make the Visual Studio evaluate Qt objects' properties?
Related
I'm trying to configure CMake 3.24.2 to generate a Visual Studio 2019 project that uses ccache to cache the output of previous builds. For that, I'm following alternative #1 from ccache's docs, where I'm trying to configure CMake to point the compiler to a copy of ccache which I've dumped in C:/tools/ccache/cl.exe. For that purpose I'm setting CMAKE_CXX_COMPILER to point to my ccache.exe, and I'm generating the project with the following command.
cmake.exe -DCMAKE_CXX_COMPILER=C:/tools/ccache/cl.exe -G "Visual Studio 16 2019" -A Win32 -DCMAKE_INSTALL_LIBDIR=lib/win/Release/x86 -S D:\proj\testproject -B D:\proj\testproject\cmake-build-release
However, this does not work and the vs2019 project keeps on pointing to the original cl.exe command. Here's an except I've taken from D:\proj\testproject\cmake-build-release\CMakeFiles\CMakeOutput.log:
The system is: Windows - 10.0.19041.0 - AMD64
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: C:/tools/ccache/cl.exe
Build flags:
Id flags:
The output was:
0
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 2/11/2023 4:51:26 PM.
Project "D:\proj\testproject\cmake-build-release\CMakeFiles\3.24.2\CompilerIdCXX\CompilerIdCXX.vcxproj" on node 1 (default targets).
PrepareForBuild:
Creating directory "Debug\".
Creating directory "Debug\CompilerIdCXX.tlog\".
InitializeBuildStatus:
Creating "Debug\CompilerIdCXX.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin\HostX64\x86\CL.exe /c /nologo /W0 /WX- /diagnostics:column /Od /Oy- /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"Debug\\" /Fd"Debug\vc142.pdb" /external:W0 /Gd /TP /analyze- /FC /errorReport:queue CMakeCXXCompilerId.cpp
CMakeCXXCompilerId.cpp
(...)
Apparently the Visual Studio 2019 project does get the hint that it should use C:/tools/ccache/cl.exe, but for some unknown reason its ClCompile entry points to the original cl.exe.
Does anyone know what's going on for the Visual Studio 2019 insisting on not using the C++ compiler passed with CMAKE_CXX_COMPILER?
This happens because the original cl.exe is inferred from the chosen generator "Visual Studio 16 2019".
In order to switch to another compiler you should use other generator e.g. Ninja or Unix Makefiles.
There are many posts about how to set the Runtime library in Visual Studio from CMake, but in my case it seems that Visual Studio is ignoring my setting.
I would like to build google-mock with /MD. This is the default setting in the project.
In a fresh build directory, built with:
cmake -G "Visual Studio 12 2013" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:\Users\mrussell\workspace\opal2\o2win32\Libs\gtest\"1.7.0" -DCMAKE_CXX_FLAGS_RELEASE="/MD /O2 /Ob2 /D NDEBUG" ../googlemock
All my cmake variables seem correct
However, when I go to build, either via the command line (I'm used to linux..) or from Visual Studio, it uses the /MT flag.
My build command (targeting 32 bit):
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"
msbuild /m:4 /property:Configuration=%build_type% ALL_BUILD.vcxproj
Output:
ClCompile:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe /c /IC:\Users\mrussell\workspace\opal2\o2win32\Libs\gtest\g
test\include /IC:\Users\mrussell\workspace\opal2\o2win32\Libs\gtest\gtest /Zi /nologo /W4 /WX /O2 /Ob2 /Oy- /D WIN32 /D _WIND
OWS /D NDEBUG /D WIN32 /D _WINDOWS /D _UNICODE /D UNICODE /D WIN32 /D _WIN32 /D STRICT /D WIN32_LEAN_AND_MEAN /D GTEST_HAS_PT
HREAD=0 /D _HAS_EXCEPTIONS=1 /D "CMAKE_INTDIR=\"Release\"" /D _UNICODE /D UNICODE /Gm- /EHsc /MT /GS /fp:precise /Zc:wchar_t
/Zc:forScope /GR /Fo"gtest.dir\Release\\" /Fd"gtest.dir\Release\vc120.pdb" /Gd /TP /wd4127 /wd4251 /wd4275 /analyze- /errorRe
port:queue -J "C:\Users\mrussell\workspace\opal2\o2win32\Libs\gtest\gtest\src\gtest-all.cc"
(note the /MT hiding in there.)
In Visual Studio, I open the solution, choose release type Release, and in any of the targets, say gtest, Properties -> Configuration Properties -> C/C++ -> Code Generation, the Runtime Library is set to /MT, not /MD as set in the Cmake file.
Same thing happens if I try to build google-test (1.7.0)
Do I just not understand how to set these? Or is there a way to force Visual Studio to use the right flag without manually opening Visual Studio and setting it?
The CMake build systems of both google-test and google-mock aren't well behaved. They do not obey the compile options and runtime option set up by the user for good reason and override those with options that they consider reasonable for testing purposes.
To prevent the replacement of MD with MT you can set the option gtest_force_shared_crt to ON in the CMake cache. The modification of other compile options (e.g., warnings) however is done unconditionally.
I use Intel C++ Compiler v. 13 for OS Windows in MS Visual Studio 2010. This compiler support vectorize a code. I want to disable this option, but save enabled -O2 optimization. I set for this goal /Qvec- flag in Project -> Properties -> Configuration Properties -> C/C++ -> Command Line -> Additional Options window (label "Inherit from parent or project defaults" is enabled). In All options section shown these keys:
/Zi /nologo /W3 /Od /Ot /Qipo /Qopt-matmul /D "WIN32" /D "NDEBUG" /D
"_CONSOLE" /D "NOALIAS" /D "_UNICODE" /D "UNICODE" /EHsc /MT /GS /Gy
/fp:fast /QaxAVX /Zc:wchar_t /Zc:forScope /Qopenmp /Qstd=c99
/Qstd=c++11 /Fp"Release\mformat.pch" /Fa"Release\" /Fo"Release\"
/Fd"Release\vc100.pdb" /Qvec-report2 /Gd
But in compilation report output this messages:
service.cpp(164): warning : SIMD LOOP WAS VECTORIZED.
service.cpp(535): warning : SIMD LOOP WAS VECTORIZED.
service.cpp(543): warning : loop was not vectorized: nonstandard loop
is not a vectorization candidate.
etc...
And program time is not change. How i can disable vectorization and no set \Od key?
Found this in the document "A Guide to Vectorization with IntelĀ® C++ Compilers"
To allow comparisons of vectorized with unvectorized code,
vectorization may be disabled with the switch /Qvec- (Windows*) or
-no-vec (Linux* or Mac OS* X).
Lots of additional good information on the IntelĀ® Composer XE Suite page.
I'm getting the following error:
LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
I'm working on a 64 bit machine (VS2008) and I have the x64 compiler. I checked that the build is on x64.
Why isn't it compiling? Here's the build log:
echo "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.1\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" -gencode=arch=compute_20,code=\"sm_20,compute_20\" --machine 32 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin" -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MT " -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.1\include" -maxrregcount=0 --compile -o "x64\Debug/lowWrappers.cu.obj" lowWrappers.cu
In the top of the properties dialogue, there's a Platform dropdown. That should say "Active(x64)". If it says "Active(Win32)", that's your problem. Click "Configuration Manager..." in the top right, select the platform for your project, select "" and find x64. You can then delete the Win32 platform if you like.
(this might be a bit out of date...but I found a fix, since I just ran into this problem).
The short answer, in your Project Properties->Configuration Properties->CUDA RuntimeAPI->Host
set the "Target Machine Platform" to x64. (mine was at x86 despite having the platform at x64).
Make sure that any libraries you are using have also been compiled on 64 bit.
I'm trying to compile the sigc++ library on windows. I set up the project setting -> C/C++ Code generation -> Runtime library = Multi Threaded DLL (/MD) in Debug mode.
I can check the C/C++ -> Command Line All Options window that /MD is set.
When I compile this project the /MD switch is transformed to /MDd and my application crash.
I downloaded the project from here:
http://ftp.gnome.org/pub/GNOME/sources/libsigc++/2.2/libsigc++-2.2.10.tar.bz2
There is a VS2010 solution there. I want to compile this project in Debug mode, but with /MD switch.