Why Error 110 error LNK2005:?

In my project compiles fine in Debug mode, but in Release mode VS 2010 give me errors like these:

Error 79 error LNK2005: “void __cdecl std::_Xlength_error(char const *)” (?_Xlength_error@std@@YAXPBD@Z) already defined in libcpmt.lib(xthrow.obj) E:\PROJECT_01\msvcprt.lib(MSVCP100.dll)

Error 110 error LNK2005: “protected: __thiscall std::basic_ios<char,struct std::char_traits >::basic_ios<char,struct std::char_traits >(void)” (??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAE@XZ) already defined in TDICOMSerie.obj E:\PROJECT_01\msvcprt.lib(MSVCP100.dll)

Why this?
How to solve this?

Thanks

@Armando,
can you provide with a Minimal Working Example (MWE)? Which version of ITK are you using? Which version of CMake are you using? Which CMake flags have you enabled?

If we could have your CMakeLists.txt, your code if shareable and if self-contained, and concise, fellows would be in a better position to try to answer with a fix.

Also, note that if you are using ITK master, or any release tagged after ITK 5.0 Alpha 1, you will not be able to use a Visual Studio older than 2015.

Also, note that VS 2010 is almost 10 years old, and many folks are likely not to have access to such version. Also, full-feature, community-edition VS are released regularly since a few years now, and other excellent choices, such as CLion, exist, so you may want to upgrade or switch to other more modern IDE/builder.

JON HAITZ

Hi Jon.

I am using version 4.13.0 of ITK and version 3.10.0 of CMake.
The reason why I use Visual Studio 2010 is because I have a stereotactic surgery planning project developed in this environment, but it does not have registration and image fusion, which is what I am trying to do with ITK 4.13.0 and the time is against me. The ideal thing for me would be to start all over again with a modern IDE like Visual Studio 2015 or 2017.
I thank you in advance for any suggestions. I’ve been trying to make this work for some time, but I’m a novice in the use of ITK and CMake.

Attached below the file CMakeLists.txt:

CMakeLists.txt (18.6 KB)

@Armando,
unfortunately, I do not have a VS 2010 version with me, so I will not be able to reproduce your problem.

In the event that other folks have the bandwith and the resources to have a go to your issue:

  • The failure you are describing comes from your own project or from ITK?
  • Are you able to build ITK 4.13.0 statically? And if your problem comes from your own project, does ITK build dynamically?
  • The CMakeLists.txt provided looks exactly the CMakeLists.txt of ITK 4.13.0, so it is in the ITK 4.13.0 tag, no need to send it. Fellows having VS 2010 would be able to check out the tag, and build right away. Rather than the ITK CMakeLists.txt, people would need the CMakeCache.txt file of ITK to exactly reproduce the CMake flags you are using.
  • In addition, if your problem lies when building your project, you will need to provide sufficient information.

If the build error lies in ITK, which I’d dare to say is unlikely thanks to the fact that prior to a release the folks make sure that the CDash dashboard is green, you may need to read the release notes to see any pitfall and/or upgrade to ITK 4.13.1 hoping that it still matches your project’s requirements. Note that you will not find a VS 2010 build in the dashboard now due to the reason stated in my previous post.

Thanks.
JON HAITZ

Hi Jon.

The failure comes from my project, not from ITK. Because I have been able to do small test projects, for example, import and export DICOM images, using ITK 3.10.0 and I have not had any problems. Everything starts due to the configuration of the Project Properties. If I adapt the configuration to ITK, the project compiles without problems, but the project itself stops working and because it is a medical software for planning stereotactic surgeries I can not commit a change in its configuration. Initially this project was conceived since 1997 and did not contemplate the use of any graphic library. But now it is necessary to do it, and I want to take advantage of ITK and later VTK, but as far as I can verify it will not be possible for me.
Previously I compiled ITK statically but in the Properties of the Debug mode of my project it makes use of “Runtime Library = Multi-threaded DLL (/ MD)” and then I got an error. This is the reason why I needed to compile ITK dynamically and it turned out that in Debug mode I compiled the project without problems but the problem appears in the compilation in Release mode.

I greatly appreciate your response and your indications.

@Armando,
glad to read that the problem is not in ITK :relieved:.

If you are able to successfully use ITK 4.13.0 shared libraries in other smaller projects as you mentioned, then you should try to decompose your problem on your larger, surgery planning project to try to isolate it.

As said, if no MWE is provided, it will be difficult to spot the cause.

Also, note that if you use CMake to configure your project, you should not edit the project properties manually in your IDE.

The only thing that comes to my mind is that you should also specify correctly in your own project how your are linking to ITK, i.e. statically or dynamically. The related CMake documentation may be helpful.

JON HAITZ

1 Like