1 분 소요

😢상황

  • Visual Studio에서 CMake 기반 프로젝트를 빌드하는 도중 MSB3073 오류 발생
  • 특히 install 명령어를 실행할 때 다음과 같은 메시지 출력:
58>------ 빌드 시작: 프로젝트: INSTALL, 구성: Release x64 ------
58>1>
58>-- Install configuration: "Release"
58>CMake Error at deps/w32-pthreads/cmake_install.cmake:39 (file):
58>  file cannot create directory: C:/Program Files (x86)/obs-studio/bin/64bit.
58>  Maybe need administrative privileges.
58>Call Stack (most recent call first):
58>  libobs/cmake_install.cmake:42 (include)
58>  cmake_install.cmake:37 (include)
58>
58>
58>E:\DevTools\Visual Studio\IDE\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: "setlocal"
58>E:\DevTools\Visual Studio\IDE\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: E:\DevTools\Cmake\bin\cmake.exe -DBUILD_TYPE=Release -P cmake_install.cmake
58>E:\DevTools\Visual Studio\IDE\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd
58>E:\DevTools\Visual Studio\IDE\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: :cmEnd
58>E:\DevTools\Visual Studio\IDE\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
58>E:\DevTools\Visual Studio\IDE\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: :cmErrorLevel
58>E:\DevTools\Visual Studio\IDE\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: exit /b %1
58>E:\DevTools\Visual Studio\IDE\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: :cmDone
58>E:\DevTools\Visual Studio\IDE\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd
58>E:\DevTools\Visual Studio\IDE\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(166,5): error MSB3073: :VCEnd" 명령이 종료되었습니다(코드: 1)."
58>"INSTALL.vcxproj" 프로젝트를 빌드했습니다. - 실패
========== 빌드: 57개 성공, 1개 실패, 0개 최신 상태, 0개 건너뜀 ==========
========== 빌드이(가) 오전 12:26에 완료되었으며, 01:33.619 분이(가) 걸림 ==========
MSB3073: 명령 "..."이(가) 코드 1을(를) 반환했습니다.
  • 빌드 로그를 확인해 보면, 설치 대상 디렉터리에 접근 권한이 없는 것이 원인

🛠️해결법

1. 관리자 권한으로 Visual Studio 실행

  • install 단계에서 시스템 폴더에 접근하려고 하면 권한 오류 발생 가능
  • Visual Studio를 우클릭 → 관리자 권한으로 실행 하여 권한 문제 해결

2. 설치 디렉터리 변경

CMakeLists.txt 또는 빌드 명령에 설치 경로를 명시적으로 변경:

-DCMAKE_INSTALL_PREFIX="C:/MyProjects/InstallDir"

💡 쓰기 권한이 확실한 사용자 디렉터리 경로로 설정할 것


정리: 왜 이게 효과 있었는가?

  • MSB3073은 일반적으로 외부 명령 실행 중 예외가 발생했을 때 뜨는 오류
  • CMake의 install 단계는 파일 복사를 동반하므로, 폴더 권한 문제가 자주 발생
  • 설치 경로를 바꾸거나 관리자 권한을 부여함으로써 문제를 근본적으로 해결할 수 있음