MSBuild: error MSB3073 The command 'setlocal VCEnd' exited with code 1 - cmake

I am trying to build an opensource project on my machine using Visual Studio 2015 and CMake. I have followed all the steps and the prebuild checks were running properly. But when I am building the INSTALL to install the software in the folder that I have specified in the CMAKE gui, I am getting the MSB3073 error. A full description of the error is as below.
Severity Code Description Project File Line Suppression State Error
MSB3073 The command "setlocal
"C:\Program Files (x86)\CMake\bin\cmake.exe" -DBUILD_TYPE=RelWithDebInfo -P cmake_install.cmake
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd
:VCEnd" exited with code 1.
INSTALL C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets 133
I have searched for the same error and found that some people who tried to install the build in a directory without write privileges encountered this, but I have made sure that I have write access. I have even tried do this with admin rights and still not able to fix this issue.
Any help in this would be highly appreciated.

While running Visual Studio 2022, trying to build VST plug-in with code generated by cmake.
For me it showed permission access denied when creating a symbolic link.
All I had to do was run Visual Studio "As Administrator" and it worked.
Of course, you have to have Admin privileges to your machine, or you belong to a group that is allowed to "Create symbolic links" in the Local Group Policy Editor (https://developer.steinberg.help/display/VST/Preparation+on+Windows)

Sorry for being a necro but I just encountered and fixed the exact same issue, and I think it can save someone some time if I share my solution.
By looking a bit in the log before the error message, I found the last element that CMake was trying to install :
-- Installing: path-to-anaconda/anaconda3/Lib/site-packages/cv2.cp37-win_amd64.pyd
CMake Error at modules/python3/cmake_install.cmake:45 (file):
file INSTALL cannot copy file
"path-to-repo/opencv/build/lib/python3/Release/cv2.cp37-win_amd64.pyd" to
"path-to-anaconda/anaconda3/Lib/site-packages/cv2.cp37-win_amd64.pyd":
Permission denied.
Call Stack (most recent call first):
modules/cmake_install.cmake:183 (include)
cmake_install.cmake:124 (include)
Permission denied...
It was simply because I left a console with cv2 imported, so the pyd was still being used and blocked the install. This can probably extend to any other file (DLLs, .hpp) being installed, just look a bit above this obscure error message ! Nothing to do with cmake_install.cmake, at least for me.

There was an error in one of the cmake_install.cmake files and it was causing the issue. Once I fixed the issue, it worked.

Related

Building C++ Pybind11 extension with setuptools and CMake generates .so directory

I am trying to use setuptools to install a C++ library with a Pybind11 interface using CMake. For using CMake with setuptools, I am using the code in the following answer: Extending setuptools extension to use CMake in setup.py?
I am able to build the library by hand with cmake.
Unfortunately however, when executing pip install . in the root directory of my project, the build fails.
While the first call to cmake (self.spawn(['cmake', str(cwd)] + cmake_args)) finishes without any error, executing the second call (self.spawn(['cmake', '--build', '.'] + build_args)) gives me the following error:
/users/thoerman/miniconda3/envs/postproc_np_products/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot open output file /users/thoerman/postproc_np_products/build/lib.linux-x86_64-cpython-37/postproc_ops_cpp.cpython-37m-x86_64-linux-gnu.so: Is a directory
collect2: error: ld returned 1 exit status
gmake[3]: *** [/users/thoerman/postproc_np_products/build/lib.linux-x86_64-cpython-37/postproc_ops_cpp.cpython-37m-x86_64-linux-gnu.so] Error 1
gmake[2]: *** [CMakeFiles/postproc_ops_cpp.dir/all] Error 2
gmake[1]: *** [CMakeFiles/postproc_ops_cpp.dir/rule] Error 2
gmake: *** [postproc_ops_cpp] Error 2
But when running the exact same commands on the command line inside the build_temp directory, everything works just fine.
Does anyone have a hint for me, what might be going wrong?
After further digging into the problem, I found the solution myself.
The problem was with the lines
extdir = pathlib.Path(self.get_ext_fullpath(ext.name))
extdir.mkdir(parents=True, exist_ok=True)
This created a directory for the target to be built. Building the target then failed, since there was already a directory with the same name.
I was able to solve it by replacing the second line as follows:
extdir.parent.mkdir(parents=True, exist_ok=True)

Gazebo Garden installation problems with cmake and msbuild (Windows 10)

I'm installing Gazebo Garden on my Windows 10 laptop and recently had some problems regarding building the ignition libraries with cmake.
First, I had an error that make couldn't run the msbuild command. The solution to that was to add the msbuild path to the system environment variables and to delete the cmake cache as in https://stackoverflow.com/questions/4... explained.
Here may be the first source of error. I changed the MS Visual studio version to the correct version of VS 19, but was not sure about the source and build folder. I set the source code folder to /ign-ws/src/ign-cmake from the installation manual (https://gazebosim.org/docs/garden/ins...) and the build folder to a new empty folder.
It kinda worked and I went on to build the libraries, but the command
colcon build --cmake-args -DBUILD_TESTING=OFF --merge-install --packages-up-to ignition-gazebo7
gave an error again. This time the error is something about the VCtargetsPath as shown in the error code:
(ign-ws) C:\Windows\System32> colcon build --cmake-args -DBUILD_TESTING=OFF --merge-install --packages-up-to ignition-gazebo7
Starting >>> ignition-cmake3
Starting >>> ignition-tools2
--- stderr: ignition-cmake3
CMake Error at CMakeLists.txt:6 (project):
Failed to run MSBuild command:
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe
to get the value of VCTargetsPath:
Microsoft (R)-Build-Engine, Version 16.11.2+f32259642 für .NET Framework
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.
MSBUILD : error MSB1009: Die Projektdatei ist nicht vorhanden.
Schalter: VCTargetsPath.vcxproj
Exit code: 1
---
Failed <<< ignition-cmake3 [1.41s, exited with code 1]
Aborted <<< ignition-tools2 [1.27s]
Summary: 0 packages finished [14.7s]
1 package failed: ignition-cmake3
1 package aborted: ignition-tools2
2 packages had stderr output: ignition-cmake3 ignition-tools2
13 packages not processed
I couldn't find any solution connecting both errors. Is the cause of my second error the false source folder? Maybe someone can help?

Installing LLReve using Cmake. Unknown BISON_TARGET error

I am getting the following error :
CMake Error at CMakeLists.txt:9 (BISON_TARGET):
Unknown CMake command "BISON_TARGET".
when I run the command :
cmake .. -GNinja
Please tell me what to do. I tried searching on google a lot and thus came up with the additions and finally ran the command :
cmake .. -D LLVM_DIR=/usr/lib/llvm-5.0/cmake/ -D FLEX_EXECUTABLE=/usr/local/Cellar/flex/2.5.37/bin/ -D FLEX_INCLUDE_DIR=/usr/local/Cellar/flex/2.5.37/include/ -D BISON_EXECUTABLE=/usr/bin/bison
but it still shows the same error :(.
Please someone help.
Your error is occurring because the BISON_TARGET function definition has not yet been supplied. This method, as commented, is supplied by FindBISON. The error indicates that either Bison was not found on your system (hopefully, you have it installed), or cmake was ran from the wrong directory. Bison is included in the top-level CMake file via:
find_package(BISON REQUIRED)
This line to include Bison must be called before using the BISON_TARGET CMake function. The LLReve instructions for compiling this repository are explicit about which directory to run the build commands in:
Go to the llreve directory and run
cd reve
mkdir build
cd build
cmake .. -GNinja
ninja
This would run on the CMake file in the llreve/reve directory, not the llreve/reve/reve directory. Please ensure you are running CMake from the correct location, as not running cmake on the top-level CMake file will often yield errors.

How can I figure out why Linenoise is failing to install?

This is on 64-bit Windows 10 Pro with MSVC 2015. This question has a long body because I want to give full information up front, but the actual question is rather straightforward:
How can I get panda to keep the working directory around (like cpanmdoes) after an install failure so I can diagnose what went wrong?
As you can see from the log below, linenoise.dll seems to be created in the right place, but come install time, it is nowhere to be found.
The .panda-work directory in %TEMP% is gone.
I just built Rakudo from source by doing
git clone git://github.com/rakudo/rakudo.git
cd rakudo
set CFLAGS=/O2 /favor:INTEL64 /Qpar
perl Configure.pl --gen-moar --gen-nqp --backends=moar --prefix=c:/opt/perl6
nmake test
nmake install
nmake spectest ← The number of failures has gone up since the last time I tried this, but that's not related to my question
Then I installed panda by doing:
git clone --recursive git://github.com/tadzik/panda.git
cd panda
perl6 bootstrap.pl
which worked.
Then I did
panda install Task::Star
I got a test failure:
==> Building NativeHelpers::Blob
==> Testing NativeHelpers::Blob
t/00-trivial.t ..
Dubious, test returned 5 (wstat 1280, 0x500)
Failed 1/1 subtests
but I force installed that because I wanted to get to as complete an install as possible as quickly as possible.
So, forging ahead, I hit this:
C:\Users\...\Temp> panda install Linenoise
==> Fetching Linenoise
==> Building Linenoise
Microsoft (R) Program Maintenance Utility Version 14.00.24210.0
Copyright (C) Microsoft Corporation. All rights reserved.
cl -c /nologo /MT /Ox /GL /DNDEBUG /DWIN32 /DAO_ASSUME_WINDOWS98 /O2 /favor:INTEL64 /Qpar /Folinenoise.obj linenoise.c
linenoise.c
perl6 -e "mkdir 'resources'; mkdir 'resources/libraries'"
link /dll /nologo /LTCG shell32.lib ws2_32.lib mswsock.lib rpcrt4.lib advapi32.lib psapi.lib iphlpapi.lib userenv.lib /out:resources/libraries/libline
noise.dll linenoise.obj
Generating code
Finished generating code
cl /Foconstant-helper /nologo /MT /Ox /GL /DNDEBUG /DWIN32 /DAO_ASSUME_WINDOWS98 /O2 /favor:INTEL64 /Qpar constant-helper.c
constant-helper.c
Generating code
Finished generating code
perl6 fill-constants.pl lib/Linenoise.pm
==> Testing Linenoise
==> Installing Linenoise
Failed to open file C:\Users\...\Temp\.panda-work\1483278033_1\resources\libraries\linenoise.dll: no such file or directory
in any at C:\opt\perl6/share/perl6/runtime/CORE.setting.moarvm line 1
in block at C:\opt\perl6\share\perl6\site\sources\85367160D11E565B2D089507C79BC309215430D6 (Panda::Installer) line 61
in sub indir at C:\opt\perl6\share\perl6\site\sources\24811C576EF8F85E7672B26955C802BB2FC94675 (Panda::Common) line 20
in method install at C:\opt\perl6\share\perl6\site\sources\85367160D11E565B2D089507C79BC309215430D6 (Panda::Installer) line 42
in method install at C:\opt\perl6\share\perl6\site\sources\582CB7486602954A4601BDCE5A0EAC54B05DA58A (Panda) line 190
in method resolve at C:\opt\perl6\share\perl6\site\sources\582CB7486602954A4601BDCE5A0EAC54B05DA58A (Panda) line 263
in sub MAIN at C:\opt\perl6\share\perl6\site\resources\1C71F7B377C6F2C6C4707E3C25016AA25A2926B1 line 20
in block at C:\opt\perl6\share\perl6\site\resources\1C71F7B377C6F2C6C4707E3C25016AA25A2926B1 line 165
Actually thrown at:
in method throw at C:\opt\perl6/share/perl6/runtime/CORE.setting.moarvm line 1
in any at gen/moar/Metamodel.nqp line 3072
in block at C:\opt\perl6\share\perl6\site\sources\85367160D11E565B2D089507C79BC309215430D6 (Panda::Installer) line 61
in sub indir at C:\opt\perl6\share\perl6\site\sources\24811C576EF8F85E7672B26955C802BB2FC94675 (Panda::Common) line 20
in method install at C:\opt\perl6\share\perl6\site\sources\85367160D11E565B2D089507C79BC309215430D6 (Panda::Installer) line 42
in method install at C:\opt\perl6\share\perl6\site\sources\582CB7486602954A4601BDCE5A0EAC54B05DA58A (Panda) line 190
in method resolve at C:\opt\perl6\share\perl6\site\sources\582CB7486602954A4601BDCE5A0EAC54B05DA58A (Panda) line 263
in sub MAIN at C:\opt\perl6\share\perl6\site\resources\1C71F7B377C6F2C6C4707E3C25016AA25A2926B1 line 20
in block at C:\opt\perl6\share\perl6\site\resources\1C71F7B377C6F2C6C4707E3C25016AA25A2926B1 line 165
The Build.pm file for Linenoise is simply not written correctly. They are hard-coding the 'lib' prefix to the library name while also trying to use the platform library name guessing mechanism in another part. If it wants to use $*VM.platform-library-name then it needs to generate a file named linenoise.dll, not liblinenoise.dll
I'm also not sure that Linenoise works on windows even if it did install.
You should probably be using zef instead of panda. If you were, you could view the working directory used at ~/.zef/store/p6-linenoise.git

mono make install fails with "Error 1"

I've finally managed to get mono to build from sources, but make install invoked from the top build directory fails at the following point:
make[6]: Entering directory `/bld/mono/mono-4.0.0/mcs/class/System'
make install-local
WARNING: generic atexit() called from legacy shared library
make[7]: Entering directory `/bld/mono/mono-4.0.0/mcs/class/System'
MONO_PATH="./../../class/lib/build:$MONO_PATH" /bld/mono/mono-4.0.0/runtime/mono-wrapper ./../../class/lib/build/gacutil.exe /i ./../../class/lib/net_4_5/System.dll /f /root /usr/mono/lib /package 4.5
make[7]: *** [install-local] Error 1
make[7]: Leaving directory `/bld/mono/mono-4.0.0/mcs/class/System'
make[6]: *** [do-install] Error 2
Error 1 is the only error thrown.
I can run this command without errors
MONO_PATH="./../../class/lib/build:$MONO_PATH" /bld/mono/mono-4.0.0/runtime/mono-wrapper ./../../class/lib/build/gacutil.exe /i ./../../class/lib/net_4_5/System.dll /f /root /usr/mono/lib /package 4.5
And I can run the final command in mono-wrapper without errors
/bld/mono/mono-4.0.0 $ /bld/mono/mono-4.0.0/libtool --verbose --mode=execute "mono/mini/mono" --config "/bld/mono/mono-4.0.0/runtime/etc/mono/config" "mcs/class/lib/build/gacutil.exe" /i mcs/class/lib/net_4_5/System.dll /f /root /usr/mono/lib /package 4.5
But running 'make install' fails. Any ideas?
Running
make --debug=V install
revealed that it was failing when attempting to execute line 197 of mcs/build/library.make, which is:
196 install-local: $(gacutil)
197 $(GACUTIL) /i $(the_lib) /f $(gacdir_flag) /root $(GACROOT) $(package_flag)
Removing the $(package_flag) variable allowed the build to complete successfully. Caveat: I'm not sure if doing so breaks the install in other ways. Just in case...for future reference...here's the relevant entry in 'man gacutil':
COMMANDS
-i <assembly_path> [-check_refs] [-package NAME] [-root ROOTDIR]
[-gacdir GACDIR]
Installs an assembly into the global assembly cache. <assembly_path>
is the name of the file that contains the assembly manifest
The -package option can be used to also create a directory in in pre-
fix/lib/mono with the name NAME, and a symlink is created from
NAME/assembly_name to the assembly on the GAC. This is used so devel-
opers can reference a set of libraries at once.
The -root option is used to specify the "libdir" value of an installa-
tion prefix which differs from the prefix of the system GAC. Typical
automake usage is "-root $(DESTDIR)$(prefix)/lib". To access assem-
blies installed to a prefix other than the mono prefix, it is necessary
to set the MONO_GAC_PREFIX environment variable.
The -gacdir option is included for backward compatibility but is not
recommended for new code. Use the -root option instead.
Basically, -package appears to be optional.
Feel free to edit this with corrections if necessary.