I built ITK 5.4 using CMake and Visual Studio 2022. Everything compiles and links fine for most headers, but when I include <itkImageFileReader.h> in my project, I get the following linker error with file itksys-5.4.lib(SystemTools.obj):
unresolved external symbol __std_find_first_of_trivial_pos_1
Here are my build settings:
ITK built as DLL / Static library (tried both)
CMAKE_CXX_STANDARD = 17
MSVC runtime = MD
Project uses same C++ standard and runtime as ITK
All required ITK libraries linked
Other headers, e.g., <itkImage.h> work fine.
Do you have any suggestions why this symbol is missing, or how to correctly build ITK to use ImageFileReader without linker errors?
Are you pointing your project to ITK’s build directory, or an install directory? Using build directory is much more tested. I have a very similar setup, and I don’t remember encountering that error.
I ran cmake --build . --target install using the install folder because I wanted to get the headers quickly.
If I used the build folder, I would need to include many header files directly from the ITK source, which is quite large. Installing seemed easier to set up the include directories.
However, after doing this, I encountered the linker error I mentioned before.
I also noticed that some ITK documentation for building external projects recommends using CMake to create the project, but I wanted to use Visual Studio 2022 directly instead. I am not sure which folder(s) should be added to the Additional Include Directories.
I apologize if my knowledge is still limited!