wizkiz
wizkiz

Reputation: 3

Problem with installing OpenCV using Visual Studio and CMake (error code: MSB3073)

I was trying to install OpenCV to import it in some Python project. I was using this guide to build it from source. I've gotten to the 16th point without much trouble more or less. Now when I try to build the INSTALL project, I'm getting the following error:

Severity    Code    Description Project File    Line    Suppression State   Suppression State
Error   MSB3073 The command "setlocal
"E:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=Release -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)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets    148     

Double clicking this error points to <Exec/> part of this code in the Microsoft.CppCommon.targets file:

  <Target Name="PostBuildEvent" Condition="'$(PostBuildEventUseInBuild)'!='false'">
  <Message Text="%(PostBuildEvent.Message)" Condition="'%(PostBuildEvent.Message)' != '' and '%(PostBuildEvent.Command)' != ''" Importance="High" />
  <Exec Command="%(PostBuildEvent.Command)$(_BuildSuffix)" Condition="'%(PostBuildEvent.Command)' != ''"/>

Edit1: Adding the full error log I got, unless I'm looking for it in the wrong place.

2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(148,5): error MSB3073: The command "setlocal
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(148,5): error MSB3073: "E:\Program Files\CMake\bin\cmake.exe" -DBUILD_TYPE=Release -P cmake_install.cmake
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(148,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(148,5): error MSB3073: :cmEnd
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(148,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(148,5): error MSB3073: :cmErrorLevel
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(148,5): error MSB3073: exit /b %1
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(148,5): error MSB3073: :cmDone
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(148,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(148,5): error MSB3073: :VCEnd" exited with code 1.
2>Done building project "INSTALL.vcxproj" -- FAILED.
========== Build: 1 succeeded, 1 failed, 80 up-to-date, 0 skipped ==========

Upvotes: 0

Views: 1946

Answers (3)

Chris Fowl
Chris Fowl

Reputation: 566

The problem is indeed, as indicated by @arrowd, that Visual Studio's permissions are not sufficient. Just run Visual Studio as administrator and then the install will succeed.

Upvotes: 2

user16147154
user16147154

Reputation: 1

Use below steps:

  1. Navigate to your build folder
  2. Right click on ALL-BUILD.vcxproj
  3. Select properties
  4. Select Security tab
  5. Select Edit
  6. Check Full Control Box
  7. Open ALL-BUILD.vcxproj
  8. Right click on INSTALL and select Rebuild

Worked for me.

Upvotes: 0

Abdelsalam Hamdi
Abdelsalam Hamdi

Reputation: 515

Hi the solution by @arrowd worked for me. just to show the steps how to fix this issue. First go to the build folder and right click, go to security tab and click edit. check the Full control box. Open your cmd as administrator than go the same directory as Opencv.sln.
run it from there than right click on INSTAll than build

Upvotes: 0

Related Questions