Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin iOS Native linking works on Simulator, duplicate Symbols on Device

I'm trying to link complicated native project for Xamarin. It's Obj-C UI Project that depends on Native Obc-C++ wrapper over c++ library (this is embedded project): enter image description here

I have native source and test project in Xcode and everything goes fine.

Then I make fat libraries of all dependencies, add them to xamarin binding project.

enter image description here

In main project i had to setup gcc options same for simulator and device:

-vvvv -cxx --registrar:static -gcc_flags "-L${ProjectDir}/../RMSDKWrapper -dead_strip -lstdc++ -lstdc++.6.0.9 -lpthread -lsqlite3 -lxml2 -ObjC -ladept-iOS -lxml-iOS -lz -lcurl -lssl -lcrypto -ldp-iOS -lePub3-iOS -L/usr/lib -I/usr/include/libxml2"

Everything works fine on Simulator but when i'm trying to compile this for Device, linker can't link libs because of duplicate symbols. I checked all libs using 'nm' all objects are looking the same for Simulator and Device. I saw that only objects that duplicated is Obj-C++ classes in embedded wrapper (rmsdk_wrapper2.xcodeproj). nm finds that objects in wrapper lib and in lib from host project(TestRMSD.xcodeproj). But for simulator it resolves well, neither for device.

UPD XS Version: https://gist.github.com/ad1Dima/eb1cc390930e191a5454260da2410c91

Build Log: https://gist.github.com/ad1Dima/8ea8c4a271ef63efb310252234b32ae5

I need any idea how can i solve this problem.

like image 818
ad1Dima Avatar asked Jul 04 '16 05:07

ad1Dima


1 Answers

Possible reasons for this error:

  • The same native library is included twice.
  • Two distinct native libraries happen to define the same symbols.
  • A native library is not correctly built, and contains the same symbol more than once.

You can find the troubleshooting steps for the linking errors here: https://developer.xamarin.com/guides/ios/troubleshooting/mtouch-errors/#MT5212

like image 67
Prashant Cholachagudda Avatar answered Oct 23 '22 11:10

Prashant Cholachagudda