STIR icon indicating copy to clipboard operation
STIR copied to clipboard

Build error using installed STIR library with visual studio

Open robbietuk opened this issue 7 months ago • 2 comments

I am trying to create a STIR wrapper with visual studio. I have build STIR and installed it in Program Files (x86).

Using the CMake example in examples/using_installed_STIR/demo_create_image.cxx. I am able to configure, build and run this example using CMake. Notably, CMake uses the find_package(STIR 6.0 REQUIRED CONFIG) command.

Porting over to Visual Studio. I want to compile the same file examples/using_installed_STIR/demo_create_image.cxx using Visual Studio, by including the libraries.

For this I used https://stackoverflow.com/a/23882710 as my guide. STIR is installed at C:\Program Files (x86)\STIR with bin, include, lib, share directories.

Within my STIRWrapper Visual Studio project, I set the following properties:

  • "C/C++->General->Additional Include Directories field" contains C:\Program Files (x86)\STIR\include\STIR-6.2 and C:\Program Files\boost_1_82_0
  • "Linker->General->Additional Library Directories" contains C:\Program Files (x86)\STIR\lib
  • "Linker->Input->Additional Dependencies" contains (the entire *.lib content of C:\Program Files (x86)\STIR\lib
IO.lib
iterative_OSMAPOSL.lib
Shape_buildblock.lib
data_buildblock.lib
iterative_OSSPS.lib
recon_buildblock.lib
analytic_FBP2D.lib
display.lib
listmode_buildblock.lib
scatter_buildblock.lib
analytic_FBP3DRP.lib
eval_buildblock.lib
modelling_buildblock.lib
spatial_transformation_buildblock.lib
buildblock.lib
iterative_KOSMAPOSL.lib
numerics_buildblock.lib

Error Log

I have attached the full build error log file [VSSTIRBuildErrorLog.txt](https://github.com/user-attachments/files/16384510/VSSTIRBuildErrorLog.txt) but here is what I believe to be the most important bit.
....
16:39:20:181	1>    Environment Variables passed to tool:
16:39:20:181	1>      VS_UNICODE_OUTPUT=1420
16:39:20:181	1>      SARIF_OUTPUT_PIPE=1092
16:39:20:181	1>    C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.40.33807\bin\HostX64\x64\CL.exe /c /I"C:\Program Files (x86)\STIR\include\STIR-6.2" /I"C:\Program Files\boost_1_82_0" /Zi /nologo /W3 /WX- /diagnostics:column /sdl /O2 /Oi /GL /D NDEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /permissive- /Fo"x64\Release\\" /Fd"x64\Release\vc143.pdb" /external:W3 /Gd /TP /FC /errorReport:prompt STIRWrapper.cpp
16:39:20:181	1>    Tracking command:
16:39:20:181	1>    C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\Tracker.exe /d "C:\Program Files (x86)\MSBuild\15.0\FileTracker\FileTracker32.dll" /i C:\Users\Admin\source\repos\iCRcompany\XC2\STIRWrapper\x64\Release\STIRWrapper.tlog /r C:\USERS\ADMIN\SOURCE\REPOS\ICRCOMPANY\XC2\STIRWRAPPER\STIRWRAPPER.CPP /b MSBuildConsole_CancelEvent1657b85cee834ad1bed4bc82531b5c92  /c "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.40.33807\bin\HostX64\x64\CL.exe"  /c /I"C:\Program Files (x86)\STIR\include\STIR-6.2" /I"C:\Program Files\boost_1_82_0" /Zi /nologo /W3 /WX- /diagnostics:column /sdl /O2 /Oi /GL /D NDEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /permissive- /Fo"x64\Release\\" /Fd"x64\Release\vc143.pdb" /external:W3 /Gd /TP /FC /errorReport:prompt STIRWrapper.cpp
16:39:20:181	1>    STIRWrapper.cpp
16:39:21:130	1>    C:\Program Files (x86)\STIR\include\STIR-6.2\stir\Array.inl(96,16): error C2512: 'stir::NumericVectorWithOffset<stir::Array<1,elemT>,elemT>::NumericVectorWithOffset': no appropriate default constructor available
16:39:21:130	1>    C:\Program Files (x86)\STIR\include\STIR-6.2\stir\Array.inl(96,16): error C2512:         with
16:39:21:130	1>    C:\Program Files (x86)\STIR\include\STIR-6.2\stir\Array.inl(96,16): error C2512:         [
16:39:21:130	1>    C:\Program Files (x86)\STIR\include\STIR-6.2\stir\Array.inl(96,16): error C2512:             elemT=float
16:39:21:130	1>    C:\Program Files (x86)\STIR\include\STIR-6.2\stir\Array.inl(96,16): error C2512:         ]
16:39:21:171	1>    (compiling source file 'STIRWrapper.cpp')
16:39:21:171	1>        C:\Program Files (x86)\STIR\include\STIR-6.2\stir\Array.inl(96,16):
16:39:21:171	1>        while trying to match the argument list '()'
16:39:21:171	1>        C:\Program Files (x86)\STIR\include\STIR-6.2\stir\Array.inl(96,16):
16:39:21:171	1>        the template instantiation context (the oldest one first) is
16:39:21:171	1>            C:\Program Files (x86)\STIR\include\STIR-6.2\stir\Shape\Shape3DWithOrientation.h(128,19):
16:39:21:171	1>            see reference to class template instantiation 'stir::Array<2,float>' being compiled
16:39:21:171	1>            C:\Program Files (x86)\STIR\include\STIR-6.2\stir\Array.inl(135,1):
16:39:21:171	1>            while compiling class template member function 'stir::Array<2,float>::~Array(void)'
16:39:21:171	1>                C:\Users\Admin\source\repos\iCRcompany\XC2\STIRWrapper\STIRWrapper.cpp(65,40):
16:39:21:171	1>                see the first reference to 'stir::Array<2,float>::~Array' in 'main'
16:39:21:171	1>            C:\Program Files (x86)\STIR\include\STIR-6.2\stir\Array.inl(96,5):
16:39:21:171	1>            while compiling class template member function 'stir::Array<2,float>::Array(const stir::IndexRange<2> &)'
16:39:21:171	1>                C:\Program Files (x86)\STIR\include\STIR-6.2\stir\numerics\MatrixFunction.inl(184,20):
16:39:21:171	1>                see the first reference to 'stir::Array<2,float>::Array' in 'stir::diagonal_matrix'
16:39:21:172	1>    The command exited with code 2.
16:39:21:172	1>  Done executing task "CL" -- FAILED.
16:39:21:172	1>Done building target "ClCompile" in project "STIRWrapper.vcxproj" -- FAILED.
16:39:21:172	1>
16:39:21:172	1>Done building project "STIRWrapper.vcxproj" -- FAILED.
16:39:21:172	1>
16:39:21:172	1>Build FAILED.
16:39:21:172	1>
16:39:21:172	1>C:\Program Files (x86)\STIR\include\STIR-6.2\stir\Array.inl(96,16): error C2512: 'stir::NumericVectorWithOffset<stir::Array<1,elemT>,elemT>::NumericVectorWithOffset': no appropriate default constructor available
16:39:21:172	1>C:\Program Files (x86)\STIR\include\STIR-6.2\stir\Array.inl(96,16): error C2512:         with
16:39:21:172	1>C:\Program Files (x86)\STIR\include\STIR-6.2\stir\Array.inl(96,16): error C2512:         [
16:39:21:172	1>C:\Program Files (x86)\STIR\include\STIR-6.2\stir\Array.inl(96,16): error C2512:             elemT=float
16:39:21:172	1>C:\Program Files (x86)\STIR\include\STIR-6.2\stir\Array.inl(96,16): error C2512:         ]
16:39:21:172	1>    0 Warning(s)
16:39:21:172	1>    1 Error(s)
16:39:21:172	1>
16:39:21:172	1>Time Elapsed 00:00:01.09
16:39:21:197	========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
16:39:21:197	========== Build completed at 4:39 PM and took 01.276 seconds ==========

I believe this to be an issue with the includes as this error occurs at the build stage. Has anyone else ever encountered this issue? My guess is find_package(STIR 6.0 REQUIRED CONFIG) is doing something with the Includes that I am missing in Visual Studio. Any recommendations on how to proceed?

robbietuk avatar Jul 25 '24 23:07 robbietuk