Error building ITK 5.4 with CMake on MSVC 19.44: unresolved external symbol __std_find_first_of_trivial_pos_1

Hi ITK team,

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?

Thanks in advance!

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.

1 Like

This error sounds like a build gone wrong. Can you try clean and rebuild ITK? Does the problem still persist?

1 Like

Thanks, sir! I’ll try again — really appreciate your help.

Dear Sir,

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!

If I build my project using CMake, it works correctly.
CMake can find ITK, link all the required modules, and the program runs without errors.

However, when I try to use Visual Studio 2022 directly, I manually add:

  • the install/include folder to Additional Include Directories

  • the install/lib folder to Additional Library Directories

  • the ITK .lib files to Input → Additional Dependencies

When I build my project this way, Visual Studio gives me the linker error I mentioned earlier.

These are all the steps I performed. I think the issue happens because I am not using CMake to build my project.

Thank you for your help, sir.

1 Like

Take a look at this:

1 Like

Thank you, sir!