Compiling Cling with Visual Studio - c++

I am trying to build cling for Windows using Visual Studio. After all the steps were completed as shown below, I don't seem to have the cling.exe in the directory /cling/build/Debug/bin for some reason. There's a clang.exe, clang++.exe and a bunch of random llvm ones but it seems that only cling.exe is missing. Does anyone know if I am missing some steps or what went wrong?
// Install CMake 3.6.0 and Visual Studio Express 2015 for Windows desktop
git clone root.cern.ch/git/llvm.git src
cd src
git checkout cling-patches
cd tools
git clone root.cern.ch/git/cling.git
git clone root.cern.ch/git/clang.git
cd clang
git checkout cling-patches
cd ../..
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=[Install Path] ..\src -G "Visual Studio 14"
//Go inside build directory and open LLVM.sln, run "Build Solution" on "Debug" and "Win32"

I guess it doesn't work for Windows currently but it will be ready in a couple of week.
https://root.cern.ch/phpBB3/viewtopic.php?f=21&t=22006&sid=b9bc976106f30bdd02d48427a88aa04e

Related

new build issues in azure pipeline windows

I have a C++ project which is built with Visual Studio 2019. I started to get strange build errors in Azure Pipeline in December. Before then, the build test had passed all the time. The build is still fine on my Windows machines. It has issues only in Azure Pipeline. I get this error
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\include\memory(619,23): error C3861: '__iso_volatile_load32': identifier not found [D:\a\1\s\build\ode\raisimODE.vcxproj]
The error message seems like it is looking for ARM instructions. Here is a snippet of my build script
cd $(Build.Repository.LocalPath)
mkdir build
cd build
cmake -Q .. -G "Visual Studio 16 2019" -A x64 -DRAISIM_TEST=ON -DCMAKE_PREFIX_PATH=$(Pipeline.Workspace)\dep\raisim_env
cmake --build . --config Release
ctest -VV -C Release
cd $(Build.Repository.LocalPath)

Compile c++ project without makefile neither CMakeLists.txt

How can I easily compile a c++ project ( https://github.com/eduardovera/D-KHT ) that doesn't have any makefile neither CMakeLists.txt?
Projects that don't have a build script, and are not header-only libraries, are virtually useless. Building them manually requires issuance of dozens or hundreds of commands, and is not tractable. Build scripts are there for a reason. Use them! They make hard work easy. If you use them properly, that is.
There is some confusion in your project: Qt Creator is an IDE. You don't need it to build anything.
Building qmake-based Projects From Command Line
macOS/Linux
# assume the git checkout is in the wc folder in the current directory
# uses system default Qt installation
mkdir build
cd build
qmake ../src
make
Windows Command Prompt
:: Assume the git checkout is in the wc folder in the current directory
:: BuildTools can be also Community, Professional or Enterprise - based on what
:: Visual Studio variant you have installed
:: 2019 can be 2017 (again - depends on what you got)
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall x64
mkdir build
cd build
C:\Qt\5.15.0\msvc2019_64\bin\qmake ..\src
nmake
:: For faster builds, use jom instead of nmake:
C:\Qt\Tools\QtCreator\bin\jom
Note that the path to visual studio installation and the path to Qt installation effectively select the compiler and Qt version. Do not modify the global environment PATH! Instead, you could add a bin folder to your home directory, add that to the path, and add symlinks there to your chosen vcvarsall.bat and qmake.exe.
CMake
But in any case - don't use qmake and make. Use cmake and ninja instead. You'd replace all qmake calls with cmake, and all [n]make calls with ninja. To pass Qt installation path to cmake, use the following options: -DCMAKE_PREFIX_PATH=<path to your Qt install>
macOS/Linux
# assume the git checkout is in the wc folder in the current directory
mkdir build
cd build
cmake -GNinja ../src
ninja
Windows Command Prompt
:: Assume the git checkout is in the wc folder in the current directory
:: BuildTools can be also Community, Professional or Enterprise - based on what
:: Visual Studio variant you have installed
:: 2019 can be 2017 (again - depends on what you got)
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall x64
mkdir build
cd build
C:\Qt\Tools\CMake_64\bin\cmake -GNinja -DCMAKE_PREFIX_PATH=C:\Qt\5.15.0\msvc2019_64 ..\src
C:\Qt\Tools\Ninja\ninja
When to Run What
Once in a Given Command Prompt
On Windows, the vcvarsall script has to run only once in any given command prompt window. It sets up environment variables needed to find and run the compiler and related tools.
Once in a Given Build Folder
The build script generators qmake and cmake need to be run only once in a given build folder. But qmake is abysmal at dealing with changes that go too far, so in practice you often have to re-run it manually. cmake normally has no such problems - it will re-run itself as needed.
Once Per Build
The build tool itself: ninja, ideally. Or make (on Unix), or jom (on Windows), or nmake (on Windows, if you hate yourself - it's slow).
If a cmake support is missing for an open source project, you can add it.
I created one that let's you run main.cpp, which seemed to be what you wanted. But lacking Qt on my computer, I dropped the dependency to it. I tried with Visual Studio 2019 and it seems to work with the examples in the repo. (Note that you have to create a folder "output" before you run though.)
You should be able to clone https://github.com/eduardovera/D-KHT/pull/3 and run cmake like normal now.
The easiest way to compile a c++ program is to go to your terminal find where your file is stored cd into that path, and then use g++ filename.cpp. And when you run it use ./a.out.

error: command 'C:\\ Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

Hi so I was trying to pip install python-ldap using my git bash but at first it told me that i don't have cl.exe so i downloaded the visual studio C++ pack now it's showing this error
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
I never coded with C++ so I'm not sure what the error is. I downloaded the CLI tools for C++ too and I don't think it's because the cl.exe isn't in the path since it found it. Any insights ??
Install Visual C++ 2015 Build Tools from https://go.microsoft.com/fwlink/?LinkId=691126 with default selection.
I know this question was asked years ago, but for future users, I thought of providing an answer for this question. Today I've faced the same problem with the "Microsoft visual studio 2019 build tool."
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
I have come across this issue while trying to install the dependency through anaconda3 cmd in windows OS.
pip install sparse_dot_topn
I have tried different methods suggest in different portals and couldn't resolve this for hours. At the same time, I've ended up installing unnecessary components of the visual studio build tool as well. Finally, I found the problem is associated with the setup tool library, and the problem can be solved through force upgrade to the setup tool package
python -m pip install -U pip setuptools
There doesn't seem to be a valid solution for this error but one workaround is to install the windows binary package from https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap
In my case, I had to copy or link (using link shell extension) the x64 version of "C Connector" to the x86 folder.
If you can't find the x64 C connector...
Download mysql-installer-web-community-8.0.12.0.msi from their website:
https://dev.mysql.com/downloads/installer/
Run the Installer, and click the Add button on the right, then locate the Connector C 6.1 x64
The C++ Connector has C compatible header files, but hard-linking to it does not work, as explained here: https://dev.mysql.com/downloads/connector/c/
You cannot install the x86 version alongside the x64 version. The installer does not permit this.
Otherwise, Hard-Link the x64 version
Install link shell extension.
Navigate to "C:\Program Files\MySQL\" then right click on "MySQL Connector C 6.1" and click Pick Link Source
Navigate to "C:\Program Files (x86)\MySQL\" and Drop Link As... > Junction
A Junction is a duplicate reference in the file system to a folder. Creating a second junction reclassifies the original folder a junction as well, but they are both authentic references to the same folder, and so, unlike symbolic links, they will work with scripts, because they are real, and are implemented on the file system level.
Then, if the connector you have installed is a different version number and you want to try to force it to work with a non-compatible script, rename it to match the folder mentioned in the error message. For example...
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726
\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 "-I C:\Program Files (x86)\MySQL\MySQL Connector C 6.1 \include" "-Ic:\program files\python37\include" "-Ic:\program files\python37\include" "-IC:\Program Files (x86)\Microsoft Visu...
Crappy pip code failing to pass variables from the system environment :(
I had a similar issue.
I had installed a 32-bit python interpreter from https://www.python.org/downloads/windows/ mistakenly in my 64-bit windows machine.
Then I downloaded the correct 64-bit interpreter setup and installed it. Then I pointed the Pycharm interpreter path to it.
Then my issue was solved. I hope this will help you...
When I was perusing the internet to find the solution I ran into an adjacent problem:
Python was not found, which I solved by (assuming your python works and is added to PATH) going to Settings > Manage App Execution Aliases and turning off "python". They try installing your package again
Install the C++ build tools from here: https://my.visualstudio.com/Downloads
Search for 'build tools' and download the latest VS build tools installer. Install the C++ build tools (currently it's called "Desktop Development with C++") with the defaults.
What worked for me in the same situation: Except installing VS Build Tools, install whole Visual Studio. Python libs often require C/C++ compiler
I had the same error; although when installing lux-api
What worked for me was downgrading the default python version 3.10 -> 3.9
(ref)
p.s. the error that I had was the following
error: command ...\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe failed with exit code 2
----------------------------------------
ERROR: Failed building wheel for pandas
Failed to build pandas
ERROR: Could not build wheels for pandas, which is required to install pyproject.toml-based projects
I had the similar issue. I was trying to build pandas from source. I figured out that my build tools were not compatible with the source. I had MSVC v142 installed. So I installed the below components and this worked for me:
Windows 10 SDK (10.0.17763.0)
MSVC v141 - VS 2017 C++x64/x86 build tools
These tools can also be installed from cmd, just install visual studio 2019 build tools exe and then run this command in cmd as admin:
vs_buildtools.exe --quiet --wait --norestart --nocache ^
--installPath C:\BuildTools ^
--add "Microsoft.VisualStudio.Workload.VCTools;includeRecommended" ^
--add Microsoft.VisualStudio.Component.VC.v141 ^
--add Microsoft.VisualStudio.Component.VC.v141.x86.x64 ^
--add Microsoft.VisualStudio.Component.Windows10SDK.17763
I also had to install additional tools to make it work correctly:
C++/CLI Support for v141 build tools (14.16)
Once the tools were installed correctly then I had to initialize x64 environment with new installed build tools:
"C:\BuildTools\VC\Auxiliary\Build\vcvars64.bat" -vcvars_ver=14.16 10.0.17763.0
After that I restarted my computer and build pandas again and it was build successfully.

How to install pbrt-v3 on windows10 with Visual Studio 2017?

I fork the repo and download it, then open it in the Visual Studio 2017 community and did as follows:
1:right-click the MakeLists.txt and click the Rebuild All. (x64 Debug)
2:Then, i found the build directory at here:C:\Users\SHIZU-NOTEBOOK\AppData\Local\CMakeBuild\233159a3-9dca-9735-91fc-be7911e3ef6d\build\x64-Debug\Debug
I can't find the directory like *\bin, also in cmd "pbrt" dosen't work.
Am I wrong with build?and solution!
Sincerely!
Use the cmake-gui or cmake command line tool to generate Visual Studio solution file, then build the solution.
If you choose the command line, here are steps:
Generate solution files
mkdir build && cd build
cmake .. -G "Visual Studio 15 Win64"
Now, open PBRT-V3.sln with Visual Studio 2017
Buile the solution
PS: from the readme in pbrt-v3 project, you need run git submodule update --init --recursive to fetch the dependencies.

libzip with Visual Studio 2010

How can I compile libzip for Visual Studio 2010?
Edit:
Before starting on the answer provided here, it appears that this may no longer be an issue going by #Thomas Klausner's answer below.
The following should get you a VS10 solution:
If you've not already done so, install CMake
Download and extract zlib to e.g. C:\devel. The download links are about halfway down the homepage. Currently this provides zlib version 1.2.7.
To work around this CMake bug which affects 64-bit Windows only, add
if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND MSVC)
set_target_properties(zlibstatic PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64")
endif()
to the end of C:\devel\zlib-1.2.7\CMakeLists.txt
Download and extract libzip to e.g. C:\devel
In a VS10 command prompt, cd C:\devel\zlib-1.2.7
mkdir build && cd build
cmake .. -G"Visual Studio 10" -DCMAKE_INSTALL_PREFIX="C:\devel\installed\zlib" This sets the install path to C:\devel\installed\zlib rather than the default C:\Program Files\zlib. For 64-bit Windows, use "Visual Studio 10 Win64" as the -G parameter.
msbuild /P:Configuration=Debug INSTALL.vcxproj
msbuild /P:Configuration=Release INSTALL.vcxproj
cd C:\devel\libzip-0.10.1
mkdir build && cd build
cmake .. -G"Visual Studio 10" -DCMAKE_PREFIX_PATH="C:\devel\installed\zlib" Set the path to wherever you installed zlib so that CMake can find zlib's include files and libs. Again, for 64-bit Windows, use "Visual Studio 10 Win64" as the -G parameter.
This should result in C:\devel\libzip-0.10.1\build\libzip.sln. It looks like there are a few POSIX-specific problems in the code, but they should hopefully be fairly easy to resolve (e.g. in zipconf.h #include <inttypes.h> needs replaced with #include <stdint.h>; there are some snprintf calls needing replaced e.g. with _snprintf).
I can't comment, so just in addition to Fraser's answer: In the last days, libzip's latest repository version should compile on VS without additional patches. Please try it out and let the developers know if parts are still missing.
Can't comment on answer above but was trying to get this to work and in the end found that the Output directory under the configuration properties and the comand in debugging.
You can remove ALL_BUILD, ZERO_CHECK, INSTALL and PACKAGE and it will build fine without any of the linking errors or linux specific errors.
Using libzip-1.0.1, zlib-1.2.8, and VS Community 2013.
Added to path:
C:\Program Files (x86)\CMake\bin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319
The cmake line became:
cmake .. -G"Visual Studio 12 Win64" -DCMAKE_INSTALL_PREFIX="C:\devel\installed\zlib"
devel\libzip-1.0.1\lib\zip_source_filep.c:189 changed:
mask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
to:
mask = umask(_S_IREAD | _S_IWRITE);
Using
an environment variable %ZLIB_DIR% for the path to zlib-1.2.8,
%LIBZIP_DIR% for the path to libzip-1.0.1
VS 2015 Express Edition, and
the file %LIBZIP_DIR%/lib/zip_source_filep.c patched according to http://hg.nih.at/libzip/rev/80457805a1e7 ,
the process for building zlib and libzip becomes this:
Building zlib
> cd /d %ZLIB_DIR% && md build & cd build
> cmake .. -G"Visual Studio 14 2015 Win64"- DCMAKE_INSTALL_PREFIX="%ZLIB_DIR%"
> msbuild /P:Configuration=Debug INSTALL.vcxproj
> msbuild /P:Configuration=Release INSTALL.vcxproj
Building libzip
> cd /d %LIBZIP_DIR% && md build & cd build
> cmake .. -G"Visual Studio 14 2015 Win64" -DCMAKE_PREFIX_PATH="%ZLIB_DIR%"
> msbuild /P:Configuration=Debug ALL_BUILD.vcxproj
> msbuild /P:Configuration=Release ALL_BUILD.vcxproj
Done!
(So you see, #MikeLischke, CMake does indeed work out-of-the-box sometimes...)
In current zlib version, there is a contrib for this:
zlib-1.2.8\contrib\vstudio\vc10\zlibvc.sln
I got an error on load because one of the configurations wasn't valid on my machine, but a recompile took care of that. I also had to change the project properties>Configuration Properties>Linker>Input>Additional Dependencies for the Debug configuration to change zlibwapi.lib to zlibwapid.lib.
In Visual Studio 2015, Win64:
If building libzip failing with a message like this:
Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.8").
All you have to do is copy the generated 'zlib.dll/zlibd.zll' and 'zlib.lib/zlibd.lib' to the top of the zlib directory (where the .h/.c files are).
The answer given by Christian Severin helped me a lot, but needed some updates for VS2019 and 32-bit:
When building with VS 2019, you must use the -A option, not use "Win64".
When building with VS 2019, the 32-bit archive is "Win32", not x86.
The "Building zlib" section has a typo, it must be Win64" -DCMAKE_..., with a space before the dash
Here is a working example with VS2019 and 32-bit build:
cd /d %ZLIB_DIR% && md build & cd build
cmake .. -G"Visual Studio 16 2019" -DCMAKE_INSTALL_PREFIX="%ZLIB_DIR%" -AWin32
msbuild /P:Configuration=Release INSTALL.vcxproj
cd /d %LIBZIP_DIR% && md build & cd build
cmake .. -G"Visual Studio 16 2019" -DCMAKE_INSTALL_PREFIX="%ZLIB_DIR%" -AWin32
msbuild /P:Configuration=Release ALL_BUILD.vcxproj