CUDA+VisualStudio compilation fails with: A single input file is required for a non-link phase when an outputfile is specified
Compiling the colmap library with latest CMake 3.28.1 and latest CUDA 12.3.2 fails both with the VS and Ninja generators.
There are two main issues:
- The
/EHsc
flag is directly passed to nvcc but should only be included in the-Xcompiler
argument (applies to both VS/Ninja) - The pdb file path passed through
-Xcompiler
is not quoted (applies to Ninja)
Replicate the issue (note that vcpkg defaults to CMake 3.27.X but the same issue happens under 3.28.1):
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg.exe install colmap[cuda-redist]:x64-windows`
...
The error logs then show the following:
FAILED: src/colmap/mvs/CMakeFiles/colmap_mvs_cuda.dir/gpu_mat_prng.cu.obj
C:\PROGRA~1\NVIDIA~2\CUDA\v12.3\bin\nvcc.exe -forward-unknown-to-host-compiler -DCOLMAP_CGAL_ENABLED -DCOLMAP_CUDA_ENABLED -DCOLMAP_GPU_ENABLED -DCOLMAP_GUI_ENABLED -DCOLMAP_OPENGL_ENABLED -DCOLMAP_OPENMP_ENABLED -DGFLAGS_IS_A_DLL=1 -DGLOG_NO_ABBREVIATED_SEVERITIES -DGL_GLEXT_PROTOTYPES -DIMATH_DLL -DNOMINMAX -DOPENEXR_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DWIN32_LEAN_AND_MEAN -D_MWAITXINTRIN_H_INCLUDED -IC:\dev\colmap\src -isystem C:\dev\vcpkg\installed\x64-windows-release\include -isystem C:\dev\vcpkg\installed\x64-windows-release\include\eigen3 -isystem C:\dev\vcpkg\installed\x64-windows-release\include\qt5 -isystem C:\dev\vcpkg\installed\x64-windows-release\include\qt5\QtCore -isystem C:\dev\vcpkg\installed\x64-windows-release\tools\qt5\mkspecs\win32-msvc -isystem C:\dev\vcpkg\installed\x64-windows-release\include\qt5\QtOpenGL -isystem C:\dev\vcpkg\installed\x64-windows-release\include\qt5\QtWidgets -isystem C:\dev\vcpkg\installed\x64-windows-release\include\qt5\QtGui -isystem C:\dev\vcpkg\installed\x64-windows-release\include\webp -isystem C:\dev\vcpkg\installed\x64-windows-release\include\OpenEXR -isystem C:\dev\vcpkg\installed\x64-windows-release\include\Imath -isystem "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.3\include" -D_WINDOWS -Xcompiler="/W3 /GR /EHsc" -Xcompiler="-MD -O2 -Ob2" -DNDEBUG -std=c++14 "--generate-code=arch=compute_70,code=[compute_70,sm_70]" /EHsc -MD -MT src\colmap\mvs\CMakeFiles\colmap_mvs_cuda.dir\gpu_mat_prng.cu.obj -MF src\colmap\mvs\CMakeFiles\colmap_mvs_cuda.dir\gpu_mat_prng.cu.obj.d -x cu -c C:\dev\colmap\src\colmap\mvs\gpu_mat_prng.cu -o src\colmap\mvs\CMakeFiles\colmap_mvs_cuda.dir\gpu_mat_prng.cu.obj -Xcompiler=-Fdsrc\colmap\mvs\CMakeFiles\colmap_mvs_cuda.dir\colmap_mvs_cuda.pdb,-FS
nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified
Executing the above command manually by quoting -Xcompiler="-Fdsrc\colmap\mvs\CMakeFiles\colmap_mvs_cuda.dir\colmap_mvs_cuda.pdb,-FS"
and removing the /EHsc
flag (keeping the ones passed through -Xcompiler
) fixes the issue.
Edited by Johannes Schönberger