isl-org / Open3D

Open3D: A Modern Library for 3D Data Processing
http://www.open3d.org
Other
11.31k stars 2.29k forks source link

How to solve "zlib multiple defined symbol" error, with open3d v0.16.0 and VS2019? #5608

Open 1939938853 opened 1 year ago

1939938853 commented 1 year ago

Checklist

My Question

Dear open3d developer

When I build open3d v0.16.0 and VS2019, I got zlib multiple defined symbol issue, see below. How to solve it?

Thank you!

` Severity Code Description Project File Line Suppression State Error MSB8066 Custom build for 'D:\git\open3d_0.15\build_0.16\CMakeFiles\5ef9c6b1004a79529d8b433530887f53\ext_zlib-build.rule;D:\git\open3d_0.15\build_0.16\CMakeFiles\5ef9c6b1004a79529d8b433530887f53\ext_zlib-install.rule;D:\git\open3d_0.15\build_0.16\CMakeFiles\0dcc2ef3167d87326574770afabe7d39\ext_zlib-complete.rule;D:\git\open3d_0.15\build_0.16\CMakeFiles\120eb681c97351abe762cc432ece25cf\ext_zlib.rule' exited with code 1. ext_zlib (ExternalProjectTargets\ext_zlib\ext_zlib) C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets 241 Error LNK2005 get_crc_table already defined in crc32.obj [D:\git\open3d_0.15\build_0.16\zlib\src\ext_zlib-build\zlib.vcxproj] ext_zlib (ExternalProjectTargets\ext_zlib\ext_zlib) D:\git\open3d_0.15\build0.16\zlib.lib(zlib1.dll) 1
Error LNK2005 inflateInit2
already defined in inflate.obj [D:\git\open3d_0.15\build_0.16\zlib\src\ext_zlib-build\zlib.vcxproj] ext_zlib (ExternalProjectTargets\ext_zlib\ext_zlib) D:\git\open3d_0.15\build_0.16\zlib.lib(zlib1.dll) 1
Error LNK2005 inflateEnd already defined in inflate.obj [D:\git\open3d_0.15\build_0.16\zlib\src\ext_zlib-build\zlib.vcxproj] ext_zlib (ExternalProjectTargets\ext_zlib\ext_zlib) D:\git\open3d_0.15\build_0.16\zlib.lib(zlib1.dll) 1
Error LNK2005 inflate already defined in inflate.obj [D:\git\open3d_0.15\build_0.16\zlib\src\ext_zlib-build\zlib.vcxproj] ext_zlib (ExternalProjectTargets\ext_zlib\ext_zlib) D:\git\open3d_0.15\build_0.16\zlib.lib(zlib1.dll) 1
Error LNK1169 one or more multiply defined symbols found [D:\git\open3d_0.15\build_0.16\zlib\src\ext_zlib-build\zlib.vcxproj] ext_zlib (ExternalProjectTargets\ext_zlib\ext_zlib) D:\git\open3d_0.15\build_0.16\zlib\src\ext_zlib-build\Release\zlib.dll 1
Error LNK2005 crc32 already defined in crc32.obj [D:\git\open3d_0.15\build_0.16\zlib\src\ext_zlib-build\zlib.vcxproj] ext_zlib (ExternalProjectTargets\ext_zlib\ext_zlib) D:\git\open3d_0.15\build_0.16\zlib.lib(zlib1.dll) 1

`

SindreYang commented 1 year ago

https://learn.microsoft.com/zh-cn/cpp/build/reference/force-force-file-output?view=msvc-170

If Open cuda(11.6) then add "/FORCE:MULTIPLE"-->(Cuda11.6 seems to have zlib)

CMAKE_MODULE_LINKER=/FORCE:MULTIPLE

You can also copy the zlib package compiled by others; image

DavidV1603 commented 1 year ago

Hello,

did you find a solution, that fixed this error for you? In my Visual Studio solution, I cannot find the dialog from @SindreYang and to be honest, I don't know, where else to put the proposed argument for FORCE:MULTIPLE

DavidV1603 commented 1 year ago

If anyone sees this: I've solved it by manually build zlib (without the changes from the Open3D patch) and add this in the build of Open3D. After that, in Visual Studio I selected Open3D -> Properties -> Linker -> General -> Force File Output and set it to /FORCE:MULTIPLE