When building custom template in release mode getting error

I am following all build steps mentioned in [readthedocs] for release (Windows — 3D Slicer documentation)

I have tried both the way command line build and GUI build. but getting same error as bellow.

    Couldn't open file 'C:/BR/LibFFI-build/objlib.dir/Release/debug.obj' with CreateFile()
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(150
,5): error MSB3073: The command "setlocal [C:\BR\LibFFI-build\ffi_shared.vcxproj] [C:\BR\slicersources-build\LibFFI.vcx
proj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(150
,5): error MSB3073: cd C:\BR\LibFFI-build [C:\BR\LibFFI-build\ffi_shared.vcxproj] [C:\BR\slicersources-build\LibFFI.vcx
proj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(150
,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\BR\LibFFI-build\ffi_shared.vcxproj] [C:\BR\slicersources-buil
d\LibFFI.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(150
,5): error MSB3073: C: [C:\BR\LibFFI-build\ffi_shared.vcxproj] [C:\BR\slicersources-build\LibFFI.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(150
,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\BR\LibFFI-build\ffi_shared.vcxproj] [C:\BR\slicersources-buil
d\LibFFI.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(150
,5): error MSB3073: "C:\Program Files\CMake\bin\cmake.exe" -E __create_def C:/BR/LibFFI-build/ffi_shared.dir/Release/ex
ports.def C:/BR/LibFFI-build/ffi_shared.dir/Release//objects.txt [C:\BR\LibFFI-build\ffi_shared.vcxproj] [C:\BR\slicers
ources-build\LibFFI.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(150
,5): error MSB3073: if %errorlevel% neq 0 goto :cmEnd [C:\BR\LibFFI-build\ffi_shared.vcxproj] [C:\BR\slicersources-buil
d\LibFFI.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(150
,5): error MSB3073: :cmEnd [C:\BR\LibFFI-build\ffi_shared.vcxproj] [C:\BR\slicersources-build\LibFFI.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(150
,5): error MSB3073: endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone [C:\BR\LibFFI-build\ffi_shared.vcxproj] [
C:\BR\slicersources-build\LibFFI.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(150
,5): error MSB3073: :cmErrorLevel [C:\BR\LibFFI-build\ffi_shared.vcxproj] [C:\BR\slicersources-build\LibFFI.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(150
,5): error MSB3073: exit /b %1 [C:\BR\LibFFI-build\ffi_shared.vcxproj] [C:\BR\slicersources-build\LibFFI.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(150
,5): error MSB3073: :cmDone [C:\BR\LibFFI-build\ffi_shared.vcxproj] [C:\BR\slicersources-build\LibFFI.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(150
,5): error MSB3073: if %errorlevel% neq 0 goto :VCEnd [C:\BR\LibFFI-build\ffi_shared.vcxproj] [C:\BR\slicersources-buil
d\LibFFI.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(150
,5): error MSB3073: :VCEnd" exited with code 1. [C:\BR\LibFFI-build\ffi_shared.vcxproj] [C:\BR\slicersources-build\LibF
FI.vcxproj]
    Building Custom Rule C:/BR/LibFFI/CMakeLists.txt
LINK : fatal error LNK1181: cannot open input file 'C:\BR\LibFFI-build\objlib.dir\Release\debug.obj' [C:\BR\LibFFI-buil
d\ffi_static.vcxproj] [C:\BR\slicersources-build\LibFFI.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241
,5): error MSB8066: Custom build for 'C:\BR\CMakeFiles\53e8e00795af948a1cf7ab505f262965\LibFFI-mkdir.rule;C:\BR\CMakeFi
les\53e8e00795af948a1cf7ab505f262965\LibFFI-download.rule;C:\BR\CMakeFiles\53e8e00795af948a1cf7ab505f262965\LibFFI-upda
te.rule;C:\BR\CMakeFiles\53e8e00795af948a1cf7ab505f262965\LibFFI-patch.rule;C:\BR\CMakeFiles\53e8e00795af948a1cf7ab505f
262965\LibFFI-configure.rule;C:\BR\CMakeFiles\53e8e00795af948a1cf7ab505f262965\LibFFI-build.rule;C:\BR\CMakeFiles\53e8e
00795af948a1cf7ab505f262965\LibFFI-install.rule;C:\BR\CMakeFiles\53e8e00795af948a1cf7ab505f262965\LibFFI-generate_proje
ct_description.rule;C:\BR\CMakeFiles\3d8e95d19201056634839aa69f03021d\LibFFI-complete.rule;C:\BR\CMakeFiles\14e8e525956
9794af3c37f023dd5c921\LibFFI.rule' exited with code 1. [C:\BR\slicersources-build\LibFFI.vcxproj]
  Creating directories for 'OpenSSL'
  Performing download step (download, verify and extract) for 'OpenSSL'
  -- Downloading...
     dst='C:/BR/OpenSSL_1_1_1g-install-msvc1900-64.tar.gz'
     timeout='none'
  -- Using src='https://github.com/Slicer/Slicer-OpenSSL/releases/download/1.1.1g/OpenSSL_1_1_1g-install-msvc1900-64.ta
  r.gz'
  -- [download 100% complete]

full build log file is here.

:pray: Can you please help me to solve this error. Thank you

The full build log shows that the first error is this:

Couldn’t open file ‘C:/BR/LibFFI-build/objlib.dir/Release/debug.obj’ with CreateFile()

I’ve checked my Slicer builds and in the debug-mode build tree debug.obj is available at c:\D\S4D\LibFFI-build\objlib.dir\Debug\debug.obj, but there is no such file in the release-mode build tree.

Have you ever attempted to build this Slicer in this build tree in debug mode? If yes, configuring the build in debug-mode first may have enabled some debug build options that did not disappear when you switched to release mode.

You can try removing LibFFI-build, LibFFI-install, and LibFFI-prefix folders and restart the build. If that does not fix the issue then it may be easier to do a full rebuild of Slicer (removing the entire C:\BR folder) rather than try to debug it further.

Are you using the very latest Slicer master version? If you do a full rebuild it could make sense to update to the latest version.

in CMAKE we are having this two entry for build type and missing CMAKE_CONFIGURATION_TYPES entry

#adding default build type
if(NOT DEFINED CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Release)
endif()


if(NOT CMAKE_CONFIGURATION_TYPES)
  set(Slicer_DEFAULT_BUILD_TYPE "Release")
endif()

When Configuring project using CMAKE
it is taking default entry of

CMAKE_CONFIGURATION_TYPES : Debug;Release;MinSizeRel;RelWithDebInfo

To solve this we have to add this entry

CMAKE_CONFIGURATION_TYPES : Release 

So, I also encountered this error, and updating to CMake 2.22.1 (from 3.17.1) fixed it.

1 Like