JoeyDeVries / LearnOpenGL

Code repository of all OpenGL chapters from the book and its accompanying website https://learnopengl.com
https://learnopengl.com
Other
11k stars 2.8k forks source link

[MSVC] LearnOpenGL failed to build with error MSB3073 #313

Open Apriltanq opened 2 years ago

Apriltanq commented 2 years ago

LearnOpenGL failed to build with error MSB3073. It can reproduce on version 514e43052ba6625b58315dbd0e1bf172a9039a94. Could you please help look at this issue? Thank you very much. Environment Compiler version: VS2019 Operating system: Windows server 2019 Reproduce steps:

  1. Open a VS x64 command
  2. git clone https://github.com/JoeyDeVries/LearnOpenGL F:\gitP\JoeyDeVries\LearnOpenGL
  3. cd F:\gitP\JoeyDeVries\LearnOpenGL
  4. mkdir build_amd64
  5. cd build_amd64
  6. set VSCMD_SKIP_SENDTELEMETRY=1 & "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -host_arch=amd64 -arch=amd64
  7. cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.18362.0 -DCMAKE_BUILD_TYPE=Release .. 2>&1 8.msbuild /m /p:Platform=x64 /p:Configuration=Release LearnOpenGL.sln /t:Rebuild /p:BuildInParallel=true 2>&1

Error log: build.log

Error info: MSB3073: setlocal [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr__2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: "C:\Program Files\CMake\bin\cmake.exe" -E copy F:/gitP/JoeyDeVries/LearnOpenGL/src/6.pbr/2.2.1.ibl_specular/2.2.1.prefilter.fs F:/gitP/JoeyDeVries/LearnOpenGL/bin/6.pbr/Release [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: :cmEnd [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: :cmErrorLevel [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: exit /b %1 [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: :cmDone [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: setlocal [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: "C:\Program Files\CMake\bin\cmake.exe" -E copy F:/gitP/JoeyDeVries/LearnOpenGL/dlls/assimp-vc140-mt.dll F:/gitP/JoeyDeVries/LearnOpenGL/dlls/ikpMP3.dll F:/gitP/JoeyDeVries/LearnOpenGL/dlls/irrKlang.dll F:/gitP/JoeyDeVries/LearnOpenGL/bin/6.pbr/Release [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: :cmEnd [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: :cmErrorLevel [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: exit /b %1 [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: :cmDone [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: :VCEnd" exited with code 1. [F:\gitP\JoeyDeVries\LearnOpenGL\build_amd64\6.pbr2.2.1.ibl_specular.vcxproj]

Apriltanq commented 2 years ago

The project failed from commit b7e97ceeecb3fa7b615041f439ec96a100f19fcc, I saw the CMakeList.txt has been changed, and this change caused the project fail.

fangzhouxia commented 2 years ago

Hi all, I also encountered the same mistake in 6159792. Could you help look?

KawasakiNinjaH2R commented 1 year ago

We have also faced this issue on VS2022. Could you please help us in investigating it?

hongjiang-ye commented 3 months ago

The DLL copy command is placed inside the foreach shader loop, resulting in multiple attempts to copy the same DLL files simultaneously, which leads to conflicts and may cause this build error.

Use cmake -E copy_if_different instead of cmake -E copy resolves the MSB3073 build error in my environment:

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -252,7 +252,7 @@ function(create_project_from_sources chapter demo)
         if(WIN32)
             # configure_file(${SHADER} "test")
             add_custom_command(TARGET ${NAME} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${SHADER} $<TARGET_FILE_DIR:${NAME}>)
-                       add_custom_command(TARGET ${NAME} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${DLLS} $<TARGET_FILE_DIR:${NAME}>)
+                       add_custom_command(TARGET ${NAME} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DLLS} $<TARGET_FILE_DIR:${NAME}>)
         elseif(UNIX AND NOT APPLE)
             file(COPY ${SHADER} DESTINATION ${CMAKE_SOURCE_DIR}/bin/${chapter})
         elseif(APPLE)

@JoeyDeVries This seems like a minor error, would you consider fixing it in the master branch?

JoeyDeVries commented 3 months ago

@hongjiang-ye that sounds like a good fix actually. Yes, feel free to set up a PR and I'll aprove. Thank you!