How to deal with the "duplicate symbols" compilation error when adding static libraries to the MAUI iOS Binding Project.
There is a Xamarin Forms project that relies on some native libraries.
Trying to migrate it to .NET MAUI.
Android native libraries works just fine, same as in Xamarin.
For the iOS added an iOS Binding Project, then added the native libraries similarly as in the Xamarin iOS project.
There are the following libraries:
<ItemGroup> <NativeReference Include="..\..\Libraries\libindy.a"> <Kind>Static</Kind> <SmartLink>False</SmartLink> </NativeReference> <NativeReference Include="..\..\Libraries\libsodium.a"> <Kind>Static</Kind> <SmartLink>False</SmartLink> </NativeReference> <NativeReference Include="..\..\Libraries\libzmq.a"> <Kind>Static</Kind> <SmartLink>False</SmartLink> <IsCxx>True</IsCxx> </NativeReference>`
There are C libraries (libindy and libsodium) and a C++ one (libzmq). The libindy.a library depends on the libsodium.a and libzmq.a.
In the Xamarin iOS project there is also an additional MTouch argument, which I also added to the MAUI startup project:
<MtouchExtraArgs>-gcc_flags -dead_strip -v</MtouchExtraArgs>
The libraries are fat, so they work on both iPhone and simulator.
The problem is that in MAUI, the application build fails with the following error:
Error: clang++ exited with code 1: duplicate symbol '_crypto_onetimeauth_verify' in: /Users/hetzner/Desktop/TestIndyLibraries/iOSBindingLibrary/bin/Debug/net7.0-ios/iOSBindingLibrary.resources/libsodium.a(libsodium_la-crypto_onetimeauth.o) /Users/hetzner/Desktop/TestIndyLibraries/iOSBindingLibrary/bin/Debug/net7.0-ios/iOSBindingLibrary.resources/libzmq.a(src_libzmq_la-tweetnacl.o)
It found duplicated symbols in libsodium.a and libzmq.a.
I believe that the -dead_strip gcc flag helps to address the issue in Xamarin, but in .NET MAUI it is, unfortunately, not working.
Does someone encounter a similar issue or have an idea on how to solve this?
Hi @Vasile Javgurean , there is a same issue reported at GitHub - the "-gcc_flags -dead_strip" Mtouch argument doesn't work #11477 , you could follow the progress at GitHub, and it was moved to xamarin/xamarin-macios#16861
Sign in to comment