Bug 21190 - can't link native lib
Summary: can't link native lib
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 7.2.5
Hardware: PC Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-07-09 03:42 UTC by renan jegouzo
Modified: 2014-07-16 02:22 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
batch build (746 bytes, application/x-sh)
2014-07-15 11:48 UTC, renan jegouzo
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_REPRODUCIBLE

Description renan jegouzo 2014-07-09 03:42:36 UTC
I have a native lib that get error: entry point not found when linked with xamarin.
but the same lib works well with xcode

xamarin project files: https://dl.dropboxusercontent.com/u/1615919/XamarinMonkVG.zip
xcode project files: https://dl.dropboxusercontent.com/u/1615919/XcodeMonkVG.zip

I don't have this problems with other native libs.



Xamarin Studio
Version 5.1 (build 479)
Installation UUID: 2a46676f-5eb8-4569-9aa7-630cd15bdfc2
Runtime:
	Mono 3.4.0 ((no/954ed3c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 304000214

Apple Developer Tools
Xcode 5.1.1 (5085)
Build 5B1008

Xamarin.Mac
Version:

Xamarin.iOS
Version: 7.2.5.5 (Business Edition)
Hash: 87026b6
Branch: 
Build date: 2014-07-02 19:39:08-0400

Xamarin.Android
Version: 4.12.5 (Business Edition)
Android SDK: /Users/renanyoy/android sdk
	Supported Android versions:
		2.3   (API level 10)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

Build Information
Release ID: 501000479
Git revision: e5a428cec75d4cc7e6e3ccd8192a3660d013e7dc
Build date: 2014-06-26 09:28:17-04
Xamarin addins: 190d93e026e17280e75a3680ef38f2630b9228d3

Operating System
Mac OS X 10.9.4
Darwin macbook.home 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
Comment 1 Ram Chandra 2014-07-09 05:06:59 UTC
I tried this issue with the attached project and I am also getting the same behavior.

When I try to run the attached sample I am getting an Unhandled Exception:
System.EntryPointNotFoundException: vgCreateContextMNK

Screencast: http://www.screencast.com/t/hzSCeQjYY3

Application Output : https://gist.github.com/saurabh360/106758978ca757984a11
IDE logs: https://gist.github.com/saurabh360/d58100aad4e0b331f36a

Environment Info:

=== Xamarin Studio ===

Version 5.1 (build 479)
Installation UUID: 6ea47b0d-1852-4aaf-808d-373ff0a5002b
Runtime:
	Mono 3.4.0 ((no/954ed3c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 304000214

=== Apple Developer Tools ===

Xcode 5.1 (5084)
Build 5B130a

=== Xamarin.Mac ===

Version: 1.8.0.8

=== Xamarin.Android ===

Version: 4.12.4 (Business Edition)
Android SDK: /Users/jatin66/Desktop/Backup/android-sdk-macosx
	Supported Android versions:
		1.6   (API level 4)
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		3.2   (API level 13)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

=== Xamarin.iOS ===

Version: 7.2.5.5 (Business Edition)
Hash: 87026b6
Branch: 
Build date: 2014-07-02 19:39:08-0400

=== Build Information ===

Release ID: 501000479
Git revision: e5a428cec75d4cc7e6e3ccd8192a3660d013e7dc
Build date: 2014-06-26 09:28:17-04
Xamarin addins: 190d93e026e17280e75a3680ef38f2630b9228d3

=== Operating System ===

Mac OS X 10.9.3
Darwin Jatin66s-iMac.local 13.2.0 Darwin Kernel Version 13.2.0
    Thu Apr 17 23:03:13 PDT 2014
    root:xnu-2422.100.13~1/RELEASE_X86_64 x86_64
Comment 2 Rolf Bjarne Kvinge [MSFT] 2014-07-15 11:27:23 UTC
There are several problems here:

1) All the DllImports must point to "__Internal" (that's two underscores). This is because on iOS it's a static library linked into the executable, and "__Internal" tells mono to look for methods in the executable itself, instead of any shared library.

With this fix you'll get several linker errors:

  "_vgAppendPath", referenced from:
     -u command line option
  "_vgColorMatrix", referenced from:
     -u command line option
  ...

this occurs because you have several DllImports for methods that aren't included in the iOS binary. You have a couple of choices:

    # manually remove all these DllImports.
    # enable the managed linker (set "Linker Behavior" to "Link all assemblies" in the project's properties). This will remove unused code, and these DllImports fall into that category.

The second option is simpler, but results in slower builds for the simulator.

2) For some reason the symbols from the native library turns into private symbols when linked into the app, which means the DllImport mechanism we have won't find them.

I tried cloning and building https://github.com/micahpearlman/MonkVG, and the resulting library worked just fine. Exactly how did you build the native library?
Comment 3 renan jegouzo 2014-07-15 11:48:42 UTC
Created attachment 7364 [details]
batch build

I made a shell script, to build and lipo the fat lib.
how do you managed to build the fat lib, with the .xcodeproj given in the repo ?
Comment 4 Rolf Bjarne Kvinge [MSFT] 2014-07-15 17:30:03 UTC
The problem is that MonkVG compiles with -fvisibility=hidden in the Release configuration.

You can build the Debug configuration instead, and it'll work.

Alternatively you can modify the Xcode project and remove -fvisibility=hidden from Release builds (like this: https://gist.github.com/rolfbjarne/df2268cf97c9d235eba1
Comment 5 renan jegouzo 2014-07-16 02:22:53 UTC
Thanks Rolf, it works.

Sorry for this report, I was sure it was a bug.

Maybe, you could add to check this flag, in this tutorial http://developer.xamarin.com/guides/ios/advanced_topics/native_interop/