You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows10下MinGW-w64编译ITK5.3遇Pthread链接重复定义错误

编译ITK 5.3遇到的问题及咨询

一、MinGW-w64编译时的pthread函数重复定义错误

我在Windows10 64位系统上,用最新版本CMake编译ITK 5.3源码,当前已安装MinGW-w64 10版本。编译过程中出现链接错误,多数pthread函数被提示重复定义,定义分别来自libpthread.a和libitkdouble-conversion-5.2.dll.a。

我尝试添加-fcommon、--allow-multiple-definition链接选项,但问题未解决。后来了解到新版GCC默认引入了-fno-common参数,不确定是否与此有关。

二、无需Visual Studio的替代编译器咨询

想了解在Windows10上,是否有其他无需安装Visual Studio的编译器可用于编译该版本ITK?我曾尝试使用最新Windows SDK,但CMake无法生成Makefile,还出现Nmake文件未找到的错误(尽管Nmake是Windows默认CMake生成器)。

编译错误日志

[ 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

内容的提问来源于stack exchange,提问作者atanu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 21:05:21