How to link a native c++ library...

JunDuJunDu USMember ✭✭


I am following this link to link my own native library:

"To Configure Xamarin.iOS To Link the Library, on the project options for your final executable (not the library itself, but the final program) you need to add in "iOS Build"'s Extra argument (these are part of your project options) the "-gcc_flags" option followed by a quoted string that contains all the extra libraries that are required for your program..."

However, I couldn't find where in the "iOS Build" section of Options I can add extra arguments. "iOS Build" has two tabs, General and Advanced, but neither one supports extra arguments.

Thanks in advance.


  • JeffreyStedfastJeffreyStedfast USXamarin Team Xamurai

    Hi @JunDu,

    This is what you want:

  • JunDuJunDu USMember ✭✭

    Thanks. I have a Xamarin project built for iOS by other developers. The project has a C++ library to the Native References folder and uses it in the code via DLLImport. However, it does not have any external compile options in the Additional Options section. Is the gcc link step missing here? But the code is working fine.

  • JeffreyStedfastJeffreyStedfast USXamarin Team Xamurai

    I'm not sure I fully understand what you are saying, but it's possible that the C# library that includes the native c++ library in the Native References is embedding the native library by using a LinkWithAttribute which has knowledge of how to natively link the c++ library when mtouch compiles the final native app binary.

  • JunDuJunDu USMember ✭✭

    No it didn't use LinkWithAttribute.

  • JeffreyStedfastJeffreyStedfast USXamarin Team Xamurai

    Not sure how it worked, then. Or perhaps I'm just misunderstanding?

  • LarryGugerLarryGuger USMember

    Hi All,

    I am from the Microsoft C++ team and we are very interested in talking to developers that are incorporating C++ libraries into their Xamarin apps. If you are doing that I would be very excited if you would reach out to me directly. My email alias is larrygug. The domain is :-)


  • biaparbiapar ITMember ✭✭✭

    @LarryGuger Have you some tips to do this?

Sign In or Register to comment.