Forum Xamarin.iOS
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Problem Calling static C library function from C# (Entry Point Not Found Exception)

VasundharaBhimavarapuVasundharaBhimavarapu USUniversity ✭✭
edited September 2014 in Xamarin.iOS


I though it to be simple but after struggling for a day and trying all options i need some help on this.

i created a simple library with Add function in C

int Add(int a,int b) { return a+b; }

here is the c# code

[DllImport("__Internal",EntryPoint="Add")] private static extern int Add (int a, int b);

this is what i passed in additional mtouch arguments
-gcc_flags "-L${ProjectDir} -lPinvoke -force_load ${ProjectDir}/libPinvoke.a"

`nm -a libPinvoke.a

00000000000002e8 s EH_frame0
0000000000000000 T _Add

i tried EntryPoint="_Add" also but still i am getting

Entry Point Not Found Exception.

you can find both the Xcode and xamarin projects in the attached zip file.

My tools version

Xamarin Studio
Version 5.4 (build 240)
Version: (Indie Edition)
Hash: 58b46df
Build date: 2014-09-18 22:32:07-0400
Operating System
Mac OS X 10.9.5

I am targeting and using iPhone6 iOS8 simulator

Best Answer


  • after seeing a post by @RolfBjarneKvinge‌ i changed the additional touch arguments to

    -gcc_flags ${ProjectDir}/libPinvoke.a

    instead of

    -gcc_flags "-L${ProjectDir} -lPinvoke -force_load ${ProjectDir}/libPinvoke.a"

    and i got a build error saying .a file was not for the i386, so i quickly generated a fat binary for all architectures and its working now.

    although its working now, just out of curiosity if somebody knows whats the difference between the two lines above and why xamarin studio did not show any error when the second line was used which i took from the official documentation at

  • i have multiple .a files for the project so when i use

    -gcc_flags ${ProjectDir}/libPinvoke1.a ${ProjectDir}/libPinvoke2.a

    i am getting an error saying

    You should provide one root assembly only, found 2 assemblies

    what is the correct way to link multiple .a files to the project?

  • thanks @RolfBjarneKvinge‌ now i can link multiple file.

    i have around 10 to 15 different .a files, before i saw your reply i used libtool to combine all the .a files to a single .a file

    libtool -static -o libPinvoke.a ./libs/*.a

    all my .a files are in ./libs folder.

    for me this is convenient than writing each library name in the gcc arguments. just posting here for future reference

  • Can you re-post the zip file with the working example of the XCode project and the Xamarin project? I'm having the same issue right now

  • FlaviusRaduFlaviusRadu USMember

    Hello, please read this. I have the same problem and I probably got an asnwer. I am testing it now.

    Good luck.

Sign In or Register to comment.