I'm trying to compile gRPC on Windows into a DLL that is compatible with our C++ application that has to be compiled with the Visual Studio 2015 toolset.
Through the Visual Studio 2019 Installer I installed VS2019 together with the old C++ toolset (not IDE) of Visual Studio 2015.
When I open the freshly cloned gRPC source folder in VS2019 its CMake Integration creates the following CMakeSettings.json with default values:
{
// See https://go.microsoft.com//fwlink//?linkid=834763 for more information about this file.
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": ""
}
]
}
How can I specify in the CMakeSettings.json file the following -A and -T options that I could specify when using CMake on the command line or the CMake GUI?
I solved this with the help of user squarekittles:
The -T argument goes into cmakeCommandArgs.
The -A argument must not be specified or you get an error because it is specified twice. It will be set through either generator or inheritEnvironments (not sure which one).
generator has to be set to Visual Studio {installed IDE version}, not Ninja
Due to the generator change, buildCommandArgs must be changed from -v to /v:{desired verbosity level, see msbuild doc}
All of these settings can be changed from the UI. Example:
Related
I am trying to build my code with Cmake and Visual Studio 2019 Build Tools.
Note that I'm not using the IDE only the Build Tools CLI.
When I try to generate my project like this:
cmake -G "Visual Studio 16 2019" -S . -B .
CMake returns this:
Generator
Visual Studio 16 2019
could not find specified instance of Visual Studio:
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community
How can I make CMake to look for the Build Tools location and not for the IDE location?
I haven't used Visual Studio in years, but according to CMake's documentation on the Visual Studio 16 2019 generator, you can use a CMake variable or an environment variable to control which instance you use.
VS 2019 supports multiple installations on the same machine. The CMAKE_GENERATOR_INSTANCE variable may be set as a cache entry containing the absolute path to a Visual Studio instance. If the value is not specified explicitly by the user or a toolchain file, CMake queries the Visual Studio Installer to locate VS instances, chooses one, and sets the variable as a cache entry to hold the value persistently.
When CMake first chooses an instance, if the VS160COMNTOOLS environment variable is set and points to the Common7/Tools directory within one of the instances, that instance will be used. Otherwise, if more than one instance is installed we do not define which one is chosen by default.
Make sure you have all of the necessary individual components selected when installing the build tools.
Make sure CMake can find the tools (e.g. add the paths to your Path variable).
As a proof of concept for my case, I added the following to my user Path variable for lib.exe, cl.exe, link.exe, etc...:
C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64
And the following path for mt.exe and rc.exe:
C:/Program Files (x86)/Windows Kits/10/bin/10.0.18362.0/x64
I try to build the gmock library from google under windows, avialable on github from here:
https://github.com/google/googletest/tree/master/googlemock
I tried to use cmake in the cygwin console, but I could not build it.
cmake C:\Users\Username\Downloads\googlemock-master\googlemock-master\googlemock
"CMake Error: The source directory "C:UsersSETDownloadsgooglemock-mastergooglemock-mastergooglemock" does not exist.
Specify --help for usage, or press the help button on the CMake GUI."
Then I installed visual studio 2017 and opened the gmock.sln file, but also this build failed.
"Error C1083: "gtest/internal/gtest-linked_ptr.h": No such file or directory gmock C:\Users\Username\Downloads\googlemock-master\googlemock-master\googlemock\include\gmock\internal\gmock-port.h"
Does anyone have an idea how I could build this library under windows 10?
Edit: Ok, for cmake the path needs to have /../ and not ..\, but i still don't get which path I need to include in cmake
Very simple:
Under the googlemock folder, create a new folder, named build (for example);
cd build && cmake ..
Basically, you're creating a new folder for the build (preferably inside the project tree, but not necessary), cd into it, and run cmake <dir>, where <dir> is the path to CMakeLists.txt, which contains the recipe for generating the build.
That's it. Now you'll have a generated gmock.sln, which you could build with Visual Studio.
For CMake to generate Visual Studio projects, you should have the Visual Studio binaries and Windows SDK reachable from your PATH.
Finally, you need to specify a generator, using CMake's -G parameter, for telling CMake which Visual Studio version you'd like projects to be generated for.
Example of putting this together:
set PATH="C:\Program Files\Microsoft Visual Studio 14.0\VC\bin";"c:\Program Files\Windows Kits\8.1\bin\x86";%PATH%
cd build
cmake -G "Visual Studio 14 2015" ..
For additional instructions, you may refer to googletest github page:
https://github.com/google/googletest/blob/master/googletest/README.md#using-cmake
I'm making a DLL, written in C++ with Qt Creator (but no Qt stuff inside, pure homemade C++), and using a standard qmake + MinGW/g++ build process. My friend is doing the framework/main soft, and he's using Visual Studio Express 2015, and he's supposed to use my DLL inside of that. Because of that I want to use the same visual studio compiler for my project in Qt Creator.
So I noticed that Qt Creator had auto detected the Visual Studio C++ 14 compiler, which I believe is the one attached to Visual Studio Express 2015. When I create a kit with that compiler and set my project to compile with that kit, I get a suggested "Make" step which calls jom in the bin folder of my Qt Creator installation. I have no idea what this is and I get the following output (see below).
I don't know what to do from here. I also tried to create a compiler directly from the nmake executable in my Visual Studio installation, and then using it - but I get a very similar error about '-' not being recognized as an option. Any hints are greatly appreciated !
12:56:27: Starting: "C:\Qt\qtcreator-3.1.1\bin\jom.exe"
Usage: jom #commandfile
jom [options] [/f makefile] [macro definitions] [targets]
nmake compatible options:
/A build all targets
/D display build information
/E override environment variable macros
/F <filename> use the specified makefile
/G display included makefiles
/H show help
/I ignore all exit codes
/K keep going - build unrelated targets on error
/N dry run - just print commands
/NOLOGO do not print logo
/P print makefile info
/R ignore predefined rules and macros
/S silent mode
/U print content of inline files
/L same as /NOLOGO
/W print the working directory before and after other processing
/X <filename> write stderr to file.
/Y disable batch mode inference rules
jom only options:
/DUMPGRAPH show the generated dependency graph
/DUMPGRAPHDOT dump dependency graph in dot format
/J <n> use up to n processes in parallel
/KEEPTEMPFILES keep all temporary files
/VERSION print version and exit
Error: unknown command line option '-' in arguments: '/L-j4'
12:56:27: The process "C:\Qt\qtcreator-3.1.1\bin\jom.exe" exited with code 128.
Error while building/deploying project Ford_DAT_framework_DLL_as_plugin (kit: MVS Ford)
When executing step 'Make'
12:56:27: Elapsed time: 00:04.
So I used qmake -tpvc to generate a VCproj file which compiled almost immediately in Visual Studio Express 2015 which my friend uses. I guess that's a valid solution to my problem then !
I've stumbled upon problems installing clang/LLVM on my Win 7 64-bit machine for setting up Emscripten in my Visual Studio 2010 Setup. I was following the official howto from Emscripten at https://github.com/kripken/emscripten/wiki/Using-Emscripten-on-Windows and stumbled into problems regarding the needed compilation of clang/LLVM.
svn co http://llvm.org/svn/llvm-project/llvm/tags/RELEASE_32/final llvm
cd llvm\tools
svn co http://llvm.org/svn/llvm-project/cfe/tags/RELEASE_32/final clang
cd ..\\..
mkdir build
cmake -G "Visual Studio 10" ..\llvm
msbuild LLVM.sln /p:Configuration=Release
The result is alot of errors similiar to this one:
CUSTOMBUILD : error : error reading '10.0\VC\bin\llvm\tools\clang\test\Index\
pch-opaque-value.cpp' [c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\b
in\build\tools\clang\test\check-clang.vcxproj]
CUSTOMBUILD : error : error reading '10.0\VC\bin\llvm\tools\clang\test\Index\
pch-with-errors.m' [c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\
build\tools\clang\test\check-clang.vcxproj]
Obviously, a path starting at
'10.0\VC...' is totally invalid.. its missing the 'C:\Program Files (x86)\Microsoft Visual Studio ' in front.. (I've checked there is a file like that in test\Index\ - it is!
My question is: how do I fix that ?
a) Can I setup an additional include path that is like 'C:\folder\MS Visual ' (including space) ?
What I have tried so far:
a) Doing it from Visual Studio Prompt and normal Prompt. Using default and custom location.
b) Running MSBUILD like
msbuild LLVM.sln /p:Configuration=Release /p:"VCBuildAdditionalOptions= C:\Program Files (x86)\Microsoft Visual Studio "
c) Trying to change PATH/Systemroot.. Destroyed my systemroot in the meantime for unknown reasons (It complaimed about a wrong path like "C:\Program " and erased it obviously).
I am seriously stuck and dont know any further than these steps. Setting up an include path does not seem to help - though I'm wondering if the CMAKE stuff had problems with space's or what is going on.
Since the authors of Emscripten and probably LLVM call their windows support "experimental", I'm not the only one having troubles trying to set up LLVM/clang for later use with Visual Studio 2010 (not 2012..). I'm sorry for the bad formatting, for some reason SO won't allow me neat formatting today.. I'm using a nightly browser build though.
If you just need a build of LLVM, you can generate NMake Makefiles and build with nmake instead of msbuild. It seems that there is a quoting issue somewhere (might be CMake, CmakeLists.txt, msbuild, who knows).
On second thought, this might be a problem with environment variables. How did you set up PATH? Try from a new "Visual Studio Developer Command Prompt".
I want to compile QT statically , I did the following steps:
1)configure -static -debug -opensource
2)nmake sub-src but in this step I have some errors like
D:\qt\bin\rcc.exe -name mimetypes D:\qt-everywhere-opensource-src-5.0.1\
qtbase\src\corelib\mimetypes\mimetypes.qrc -o .rcc\debug_static\qrc_mimetypes.cp
p
'D:\qt\bin\rcc.exe' is not recognized as an internal or external command,
operable program or batch file.
NMAKE : fatal error U1077: 'D:\qt\bin\rcc.exe' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0
\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
what should I do?
Before trying to compile Qt 5.x, you may need to install some libraries (depends of the modules you want to compile) :
ActivePerl (** needed, as it is used to configure qtsdk)
Microsoft Windows SDK 7.1
Microsoft DirectX SDK
Python
ICU
...
If you plan to use a library (like Assimp for example) which internally use the same libraries (like zlib), you may have to overwrite these libraries, located in the qtbase\src\3rdparty sub-directories, with their latest versions.
Edit the file configure.bat, located in the qtbase directory, and comment out the line 45 :
::if not exist %QTSRC%\.gitignore goto sconf
Edit the file qmake.conf, located in qtbase\mkspecs\win32-msvc2010 (if you're using Visual Studio 2010) or in qtbase\mkspecs\win32-msvc2012 (if you're using Visual Studio 2012) :
line 9 : CONFIG += incremental flat precompile_header autogen_precompile_source debug_and_release debug_and_release_target
line 23 : QMAKE_CFLAGS_RELEASE = -O2 -MT
line 24 : QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
line 25 : QMAKE_CFLAGS_DEBUG = -Zi -MTd
Start the Visual Studio command prompt : Start > Programs > Microsoft Visual Studio 20XX > Visual Studio Tools.
Make sure that the path to Perl.exe is in the PATH environment variable : PATH=%PATH%;C:\Perl\bin (or PATH=%PATH%;C:\Perl64\bin if compiling for x64).
Go in the qtbase directory : CD \Qt\5.0.1\qtbase.
Configure Qt for compiling statically debug and release versions :
configure -developer-build -opensource -confirm-license -platform win32-msvc2010 -mp -nomake examples -nomake tests -static (if you're using Visual Studio 2010)
configure -developer-build -opensource -confirm-license -platform win32-msvc2012 -mp -nomake examples -nomake tests -static (if you're using Visual Studio 2012)
Examples and tests can be compiled later, if you need them.
If you plan to use OpenGL, add -opengl desktop to the command line, otherwise Qt will use by default OpenGL/ES which is targeted for mobile devices.
If your CPU is not multicore capable, remove the -mp option.
Go back in the parent directory : CD ...
Configure again Qt : configure -developer-build -opensource -confirm-license -platform win32-msvc20XX-opengl desktop -mp -nomake examples -nomake tests -static
(I'm not sure this step is needed, but as it takes just a few seconds...).
Compile : nmake.
Another method for compiling is to use jom and specify the number of CPU cores to use : C:\Qt\jom\jom.exe -j #NUMBER_OF_CORES#.
You will find the compiled static libraries in the qtbase\lib folder and the files to include in the sub-directories of qtbase\include.
To use them, you will have to use static run-time libraries (/MT or /MTd) in your Visual C++ project.