0

I have created a simple binding project with Xamarin. The binding project imports a static library MyLibrary.a. It also contains ApiDefinition.cs and StructAndEnum.cs made through sharpie tool.

Now I have an iOS project that links that binding project. MyLibrary.a in order to work needs some frameworks and libs (see below).

enter image description here

In order to make it working, I followed the Xamarin documentation.

In the iOS project, I added the following mtouch arguments (see also attached imaged).

--cxx -gcc_flags "-L${ProjectDir} -framework CFNetwork -framework SystemConfiguration -framework MobileCoreServices -framework Security -framework AVFoundation -libicucore -libxml2 -libc++ -libzd -libstdc++.6.0.9"

enter image description here

When I try to compile I always end with a build error.

MTOUCH: error MT5209: Native linking error: library not found for -libicucore MTOUCH: error MT5201: Native linking failed. Please review the build log and the user flags provided to gcc: -L/Users/tmp/Documents/Projects/Ovp/BindinTest.iOS -framework CFNetwork -framework SystemConfiguration -framework MobileCoreServices -framework Security -framework AVFoundation -libicucore -libxml2 -libc++ -libzd -libstdc++.6.0.9 MTOUCH: error MT5202: Native linking failed. Please review the build log.

Any clue to make it work? Maybe something is missing?

Thank you in advance.

Federico Navarrete
  • 3,069
  • 5
  • 41
  • 76
Lorenzo B
  • 33,216
  • 24
  • 116
  • 190

1 Answers1

1

-libicucore -libxml2 -libc++ -libzd -libstdc++.6.0.9

This is not how you pass library options for gcc linkage.

To link a static or dynamic library libicucore.<extension> that resides in /path/to/the/lib, the commandline options are:

-L/path/to/the/lib -licucore

Note that the lib prefix of the library name is ommitted in the -l option: the linker assumes it. And if /path/to/the/lib is one of the linker's default search directories for libraries then you can omit it. If you have another look at your Xamarin documentation you will see that libMyLibrary.a is linked with the option -lMyLibrary.

Some other things about these linkage options seem very odd to my GCC eyes, but as I know next to nothing about iOS development I won't anticipate problems that you haven't had yet.

Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182
  • Mike, yes it's my `-libicucore` is not correct. icucore is a stdlib, So, do I need to specify it as `-L/path/to/the/lib -licucore`? Thanks you. – Lorenzo B Oct 27 '15 at 10:16
  • It's not a standard GCC library, but I believe its "standard" for iOS, so I can't say if it will be found by default however your GCC toolchain is adapted for iOS. Try with no `-L` for it and see. If the library is reported not found then you'll need to discover where it resides and add an `-L` to it. – Mike Kinghan Oct 27 '15 at 10:22
  • Thanks you for your reply. Can you suggest me a good intro on GCC and gcc_flags? – Lorenzo B Oct 27 '15 at 10:41
  • 1
    [This](https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html) is as good a starter as I know, but ultimately rely on the [offical documentation for your version](https://gcc.gnu.org/onlinedocs/), e.g. [the commandline options](https://gcc.gnu.org/onlinedocs/gcc-5.2.0/gcc/index.html#toc_Invoking-GCC) `gcc_flags` is not a GCC keyword or option: I guess it is an Xamarin keyword used for passing options to GCC. – Mike Kinghan Oct 27 '15 at 11:01