In my Visual Studio Xamarin Forms iOS project, I am linking against a native (c++) library I built and deployed using Visual Studio Cross C++ Platform. I can link and run against an actual device (through the Mac Server), but I cannot get it to work through the simulator. If I build with the same link settings, the build fails, not being able to find the entrypoint. If I choose not to link, then the build succeeds but I get am Entrypointnotfoundexception when running at the point where I try to call into the native code.
-
Is there any way you can upload a sample? – Paul Jun 13 '16 at 05:36
-
I get it following the steps and code from this blog: http://kerry.lothrop.de/c-libraries/ But I also get it on more complex solutions which I've written from scratch. – PatMac Jun 14 '16 at 14:02
-
Was this solution helpful in investigating the issue? – PatMac Jul 16 '16 at 22:34
1 Answers
I just went through the example from your comment, using his sample code here. I had to do a couple things to get it to run correctly. My problem was on Xamarin.iOS, but the same steps can be applied for Xamarin.Forms, assuming you already have platform-specific integration working.
Since you have the code working on a physical device, you should already have a Native Static Reference
to your .a
library. But the iOS simulator runs on the x86_64
architecture (iOS 11 and later does not support i386
), while your device likely runs on some version/variant of ARM
. It sounds like your library is built to support only your device's architecture. You can check this by running lipo
from your Mac:
% lipo -info /usr/lib/libCLib.iOS.a
To support the sim's architecture as well (see this article), build the C++ project to the architectures you need to support, then combine them, like so:
lipo -create -output libCLib.iOS.a libCLib.iOS-x8664.a libCLib.iOS-arm64.a
Use that output .a
file as your new Native Static Reference
file back in Visual Studio. Change Supported Architectures
in your project settings to x86_64
, and that should be everything. Hope this helps somebody.

- 903
- 1
- 10
- 25
-
One more note, though possibly obvious: if you need to use the C++ compiler, you will need to add `-cxx` to the "Additional mtouch arguments" in the **iOS Build** tab of your Project settings. – Joseph Mar 13 '18 at 21:20
-
In addition to the above for the Simulator, my mtouch arguments for the iPhone were `-cxx -gcc_flags "-L${ProjectDir} -all_load"`. – Joseph Mar 21 '18 at 17:27