0

I am trying to compile itk from source, its with version 5.3. On a windows 10 64 bit machine and with mingw-w64 version 10 installed i am using cmake(latest version) to build the itk source.

How ever during build i am getting a linker error of " multiple definitions found for most of the pthread functions" coming from another source file .

As i am directly building from source and not supposed change the source files any can tell me how to avoid that error ?

I have tried with -fcommon --allow-multiple-definition linker options without any help.

Later found out that -fno-common was introduced in latest gcc versions.

also is there any way to build ITK this version with any other compiler in windows 10 ?

I have tried with windows sdk latest but that does not give me the option to generate make files through cmake. And gives a strange error of Nmake file not found even though it is a default cmake generator of windows.

Please note : I am not interested in installing visual studio . thats why cant get hold of msvc compilers.

47%] Building CXX object Modules/Core/Common/src/CMakeFiles/ITKCommon.dir/__/itkBuildInformation.cxx.obj [ 47%] Linking CXX shared library ........\bin\libITKCommon-5.2.dll c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libpthread.a(libwinpthread_la-cond.o):cond.c:(.text+0x1100): multiple definition of pthread_cond_timedwait'; ../../../../lib/libitkdouble-conversion-5.2.dll.a(d000091.o):(.text+0x0): first defined here c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libpthread.a(libwinpthread_la-thread.o):thread.c:(.text+0x14a0): multiple definition of pthread_once'; ../../../../lib/libitkdouble-conversion-5.2.dll.a(d000136.o):(.text+0x0): first defined here c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libpthread.a(libwinpthread_la-thread.o):thread.c:(.text+0x1ac0): multiple definition of pthread_self'; ../../../../lib/libitkdouble-conversion-5.2.dll.a(d000150.o):(.text+0x0): first defined here c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libpthread.a(libwinpthread_la-mutex.o):mutex.c:(.text+0x80): multiple definition of pthread_mutex_lock'; ../../../../lib/libitkdouble-conversion-5.2.dll.a(d000121.o):(.text+0x0): first defined here c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libpthread.a(libwinpthread_la-mutex.o):mutex.c:(.text+0x3a0): multiple definition of pthread_mutex_unlock'; ../../../../lib/libitkdouble-conversion-5.2.dll.a(d000124.o):(.text+0x0): first defined here c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libpthread.a(libwinpthread_la-mutex.o):mutex.c:(.text+0x520): multiple definition of pthread_mutex_init'; ../../../../lib/libitkdouble-conversion-5.2.dll.a(d000120.o):(.text+0x0): first defined here c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: c:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libpthread.a(libwinpthread_la-mutex.o):mutex.c:(.text+0x570): multiple definition of `pthread_mutex_destroy'; ../../../../lib/libitkdouble-conversion-5.2.dll.a(d000119.o):(.text+0x0): first defined here collect2.exe: error: ld returned 1 exit status mingw32-make[5]: *** [Modules\Core\Common\src\CMakeFiles\ITKCommon.dir\build.make:1772: bin/libITKCommon-5.2.dll] Error 1 mingw32-make[4]: *** [CMakeFiles\Makefile2:5302: Modules/Core/Common/src/CMakeFiles/ITKCommon.dir/all] Error 2 mingw32-make[3]: *** [Makefile:155: all] Error 2 mingw32-make[2]: *** [CMakeFiles\ITK.dir\build.make:85: ep/src/ITK-stamp/ITK-build] Error 2 mingw32-make[1]: *** [CMakeFiles\Makefile2:1082: CMakeFiles/ITK.dir/all] Error 2 mingw32-make: *** [Makefile:145: all] Error 2

1
  • You could install it directly form MSYS2 packages.msys2.org/base/mingw-w64-itk or build it yourself github.com/msys2/MINGW-packages/tree/master/mingw-w64-itk Commented Dec 14, 2023 at 20:50

1 Answer 1

1

MinGW is neither officially supported, nor tested, so it is not surprising that it doesn't work. Contributions to add support are welcome.

Microsoft offers just the command-line compiler, without needing Visual Studio. You might also have better luck with Clang for Windows than MinGW.

Sign up to request clarification or add additional context in comments.

3 Comments

I have seen MS build tools earlier and tried to download as they claim to offer cl.exe which offer msvc environment . But not sure we can use build tools without purchasing license. Can we use build tool without purchasing?
I believe so: visualstudiomagazine.com/articles/2022/08/30/… Key quote: "VSBT can be used for compiling open source C++ dependencies from source without requiring a Visual Studio license, even for developers working for an enterprise on a commercial or closed-source project."
Thanks a lot, I am using VSBT and its working so far nicely, Even clang gave me hard time to compile few part of the source code with /MT /bigobj tag erros.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.