Build 32-bit fmt with msbuild - msbuild

I am trying to build a 32-bit fmt on Windows Server 2019 using cmake/msbuild (I don't have the full Visual Studio GUI, I only have the command line build tools). I get this error:
C:\Program Files (x86)\Microsoft Visual
Studio\2019\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(408,5):
error MSB8013: This project doesn't contain the Configuration and
Platform combination of Debug|Win32.
It builds fine as 64-bit, but that isn't what I need. I assume that's because the build files generated by fmt don't have a configuration for 32-bit Windows (I don't think the Debug bit matters, it doesn't work with Release configuration either).
I'm doing this in the build subdirectory, per the fmt instructions:
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-m32 -DCMAKE_C_FLAGS=-m32 -DCMAKE_GENERATOR_PLATFORM=x86 ..
cmake --build . --config Release
cmake --install . --prefix <fmtlib_target_dir> --config Release
Is there a way to build fmt on Windows as 32-bit?

For projects which have CI builds the best documentation on how to build is usually the CI script/configuration itself; from https://github.com/fmtlib/fmt/blob/master/support/appveyor-build.py :
if image == 'Visual Studio 2019':
generator = 'Visual Studio 16 2019'
if platform == 'x64':
cmake_command.extend(['-A', 'x64'])
else:
if image == 'Visual Studio 2015':
generator = 'Visual Studio 14 2015'
elif image == 'Visual Studio 2017':
generator = 'Visual Studio 15 2017'
if platform == 'x64':
generator += ' Win64'
cmake_command.append('-G' + generator)
in other words: pass a different generator/option for 32bit builds like -G "Visual Studio 16 2019" -A Win32.

Related

CMake with Build Tools for Visual Studio 2019 (Just the CLI not the IDE)

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

CMake could not find any instance of Visual Studio, openvino

Because of avx instruction not available in my cpu, i used copy the cpu_extensionavx2.dll
removing avx2 and copy in the build folder
I had already run setupvars.bat using the command:
"C:\Program Files (x86)\IntelSWTools\openvino\bin\setupvars.bat"
It is working.
While running cmake by running this command:
"C:\Program Files\CMake\bin\cmake.exe" ^
-G "Visual Studio 14 Win64" ^
"C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\inference_engine\samples"
it throws the following error, even when I changed to visual studio 16 but gave same error:
(base) C:\Users\ra\build>
(base) C:\Users\ra\build> "C:\Program Files\CMake\bin\cmake.exe" ^
More? -G "Visual Studio 16" ^
More? "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\inferenc
e_engine\samples"
CMake Error at CMakeLists.txt:7 (project):
Generator
Visual Studio 16 2019
could not find any instance of Visual Studio.
-- Configuring incomplete, errors occurred!
See also "C:/Users/ra/build/CMakeFiles/CMakeOutput.log".
but when I used this command:
"C:\Program Files\CMake\bin\cmake.exe" ^
-G "Visual Studio 20" ^
"C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\inferene_engine\samples"
it throws generator error as:
e_engine\samples"
CMake Error at CMakeLists.txt:7 (project):
Generator
Visual Studio 15 2017
could not find any instance of Visual Studio.
-- Configuring incomplete, errors occurred!
See also "C:/Users/ra/build/CMakeFiles/CMakeOutput.log".
(base) C:\Users\ra\build> "C:\Program Files\CMake\bin\cmake.exe" ^
More? -G "Visual Studio 20" ^
More? "C:\Program Files (x86)\IntelSWTools\openvino\deployment_tools\inferenc
e_engine\samples"
CMake Error: Could not create named generator Visual Studio 20
Generators
Visual Studio 16 2019 = Generates Visual Studio 2019 project files.
Use -A option to specify architecture.
Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 10 2010 [arch] = Generates Visual Studio 2010 project files.
Optional [arch] can be "Win64" or "IA64".
Visual Studio 9 2008 [arch] = Generates Visual Studio 2008 project files.
Optional [arch] can be "Win64" or "IA64".
Borland Makefiles = Generates Borland makefiles.
* NMake Makefiles = Generates NMake makefiles.
NMake Makefiles JOM = Generates JOM makefiles.
MSYS Makefiles = Generates MSYS makefiles.
MinGW Makefiles = Generates a make file for use with
mingw32-make.
Unix Makefiles = Generates standard UNIX makefiles.
Green Hills MULTI = Generates Green Hills MULTI files
(experimental, work-in-progress).
Ninja = Generates build.ninja files.
Watcom WMake = Generates Watcom WMake makefiles.
CodeBlocks - MinGW Makefiles = Generates CodeBlocks project files.
CodeBlocks - NMake Makefiles = Generates CodeBlocks project files.
CodeBlocks - NMake Makefiles JOM
= Generates CodeBlocks project files.
CodeBlocks - Ninja = Generates CodeBlocks project files.
CodeBlocks - Unix Makefiles = Generates CodeBlocks project files.
CodeLite - MinGW Makefiles = Generates CodeLite project files.
CodeLite - NMake Makefiles = Generates CodeLite project files.
CodeLite - Ninja = Generates CodeLite project files.
CodeLite - Unix Makefiles = Generates CodeLite project files.
Sublime Text 2 - MinGW Makefiles
= Generates Sublime Text 2 project files.
Sublime Text 2 - NMake Makefiles
= Generates Sublime Text 2 project files.
Sublime Text 2 - Ninja = Generates Sublime Text 2 project files.
Sublime Text 2 - Unix Makefiles
= Generates Sublime Text 2 project files.
Kate - MinGW Makefiles = Generates Kate project files.
Kate - NMake Makefiles = Generates Kate project files.
Kate - Ninja = Generates Kate project files.
Kate - Unix Makefiles = Generates Kate project files.
Eclipse CDT4 - NMake Makefiles
= Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - MinGW Makefiles
= Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Ninja = Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
I am running Windows 7 64-bit, all are installed CMake latest version.
Help me.
You can build the demos automatically using the bat script:
"C:\Program Files (x86)\Intel\openvino_2021\inference_engine\demos\build_demos_msvc.bat"
You can also build them manually if you wish.
"C:\Program Files (x86)\Intel\openvino_2021\bin\setupvars.bat"
md build
cd build
cmake -A x64 "C:\Program Files (x86)\Intel\openvino_2021\inference_engine\demos
cmake --build . --config Release
Please ensure your system meets the system requirements and you are using a supported OS. For Windows, only Windows 10 is supported.
Processors
6th to 11th generation Intel® Core™ processors
List item 1st to 3rd generation
of Intel® Xeon® Scalable processors

Google GMOCK build libgmock.a under windows

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

cmake doesn't add the jsoncpp generated files to the bin

I used https://github.com/open-source-parsers/jsoncpp and downloaded cmake, python, scons. Followed everything that was in build guide and cmake doesn't put what is generated in the bin directory, anyone have an idea?
Using windows 7 if that helps
The instructions are very Linux-centric. I'm guessing if you're on Windows you might be using Visual Studio, in which case the following should work (I didn't use SCONS or Python):
git clone git#github.com:open-source-parsers/jsoncpp.git
mkdir build
cd build
cmake -G"Visual Studio 12 2013 Win64" ..\jsoncpp
cmake --build . --config Debug
cmake --build . --config Release
Line 4 is specifying VS 2013 as the generator targeting a 64-bit build. To create a 32-bit build, simply omit the Win64. To see all available generators, just run cmake with no args.
Once line 4 has completed, you should have a VS solution called "jsoncpp.sln" in the root of your build folder. You can either open this and build from VS, or just use CMake to invoke the compiler by running lines 5 & 6.
Building the project also causes the tests to run, some of which fail. This makes it appear that the build has failed, but in fact you should have the test exes in the bin folder (e.g. build\bin\Debug\jsoncpp_test.exe) and the library in the lib folder (e.g. build\lib\Release\jsoncpp.lib).
I'm not sure how significant the test failures are - I'd be worried if I were you :-)

Compiling clang/LLVM on win results in compile errors - how to fix?

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".