Bug 42416 - Building against SQLite.NET PCL gives errors
Summary: Building against SQLite.NET PCL gives errors
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 9.10 (C8)
Hardware: PC Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
: 42776 ()
Depends on:
Reported: 2016-07-08 00:33 UTC by Paul Johnson
Modified: 2016-07-25 22:21 UTC (History)
5 users (show)

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

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:

Description Paul Johnson 2016-07-08 00:33:59 UTC
I've a couple of packages that use 3.1.1 of SQLite.NET-PCL from nuget. When I compile I get errors such as MTOUCH: error MT5210: Native linking failed, undefined symbol: _sqlite3_column_int64. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.

Looking through the Xamarin forums, the fix of installing a different version of XI (say Alpha to Release) allows the compilation to work without the errors. If I then move back to Alpha, the builds still work, but only for a limited time (say 10 compilations) after which something happens internally and the package starts throwing up the same errors - moving back to Release and then back to Alpha fixes the issue but is a pain in the backside!

=== Xamarin Studio Business ===

Version 6.1 (build 4963)
Installation UUID: 728e2a5d-c6a2-4d84-a931-ee64cb78694c
	Mono 4.4.0 (mono-4.4.0-branch/fcf7a6d) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 404000148

=== NuGet ===


=== Xamarin.Profiler ===

Not Installed

=== Apple Developer Tools ===

Xcode 7.3.1 (10188.1)
Build 7D1014

=== Xamarin.iOS ===

Version: (Xamarin Business)
Hash: ef65ca5
Branch: master
Build date: 2016-06-07 21:27:36-0400

=== Xamarin.Mac ===

Version: (Xamarin Business)

=== Xamarin.Android ===

Version: (Xamarin Business)
Android SDK: /Users/PFJ/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		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)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.1
SDK Build Tools Version: 23.0.2

Java SDK: /usr
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)

Android Designer EPL code available here:

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Build Information ===

Release ID: 601004963
Git revision: b37c52e0249c009e308eb144957ac97d1003ec0e
Build date: 2016-06-10 12:00:02-04
Xamarin addins: db4bae9b11a32d16ee009695cd1bfa36455187b0
Build lane: monodevelop-lion-cycle8-preview2

=== Operating System ===

Mac OS X 10.11.6
Darwin Pauls-MacBook-Pro.local 15.6.0 Darwin Kernel Version 15.6.0
    Thu Jun 23 18:48:19 PDT 2016
    root:xnu-3248.60.10~2/RELEASE_X86_64 x86_64
Comment 1 kontakt 2016-07-08 13:16:00 UTC
I have the same problem and it only happens on device (I have iPhone 4 iOS 7). I have current Alpha. When I removed P/Invokes ([DllImport ("sqlite3", ...) in SQLite the build and deploy was successful, but it crashed on line 'KernelSingleton.Kernel.Load(new List<NinjectModule>() { new IOSNinjectModule() });' with error 'System.InvalidOperationException: Error loading Ninject component IModuleLoader' - I don't know if it is related, but still can't debug my app on device.
Comment 2 Sebastien Pouliot 2016-07-08 13:51:41 UTC
That happens because the .dll includes DllImport to functions that do not exists on the platform. 

This is not allowed by default as Apple's native linker does not allow this for bitcode (e.g. tvOS and watchOS) which the new XI version now supports.

You can opt-out of this (at least today for iOS) by providing the

> -dlsym=yes

option to the "Additional mtouch arguments". It will build and run fine - as long as you don't call the functions that do not exists on the platform.
Comment 3 Sebastien Pouliot 2016-07-25 21:12:18 UTC
*** Bug 42776 has been marked as a duplicate of this bug. ***
Comment 4 Cody Russell 2016-07-25 22:21:49 UTC
Why is this only an issue in Xamarin alpha channel and not in beta channel? Did something change in mtouch or Mono to be more strict about DllImport?