Bug 10685 - Linking native library failed while building solution with binding library
Summary: Linking native library failed while building solution with binding library
Status: RESOLVED DUPLICATE of bug 6998
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: 6.2.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-02-26 07:40 UTC by Alexander
Modified: 2013-07-22 10:42 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 Alexander 2013-02-26 07:40:23 UTC
I'm trying to compile binding library for ShareKit library, simulator version works fine, but compilation for device fails with linker error. Demo application built from XCode also works.

Steps to reproduce: build test solution from attachment (native library project included)

Error description:


Process exited with code 1, command:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc  -Wl,-no_pie  -miphoneos-version-min=6.1 -gdwarf-2  -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk  /var/folders/f5/t9d0pqgs10zfnmvbkr298zdr0000gn/T/tmp13b1812.tmp/TestShareKit.exe.armv7.o /var/folders/f5/t9d0pqgs10zfnmvbkr298zdr0000gn/T/tmp13b1812.tmp/ShareKit.dll.armv7.o /var/folders/f5/t9d0pqgs10zfnmvbkr298zdr0000gn/T/tmp13b1812.tmp/System.Core.dll.armv7.o /var/folders/f5/t9d0pqgs10zfnmvbkr298zdr0000gn/T/tmp13b1812.tmp/Mono.Security.dll.armv7.o /var/folders/f5/t9d0pqgs10zfnmvbkr298zdr0000gn/T/tmp13b1812.tmp/System.dll.armv7.o /var/folders/f5/t9d0pqgs10zfnmvbkr298zdr0000gn/T/tmp13b1812.tmp/monotouch.dll.armv7.o /var/folders/f5/t9d0pqgs10zfnmvbkr298zdr0000gn/T/tmp13b1812.tmp/mscorlib.dll.armv7.o /Users/alexander/projects/TestShareKit/TestShareKit/obj/Debug/mtouch-cache/main..armv7.cache.6quKWOf7CMdYW0KGSbNZ+C4vzd4=.o /Users/alexander/projects/TestShareKit/TestShareKit/obj/Debug/mtouch-cache/registrar.armv7.cache.Yc3JF9jgIt+8RLXsLvmb34EVPKU=.o -o /var/folders/f5/t9d0pqgs10zfnmvbkr298zdr0000gn/T/tmp13b1812.tmp/TestShareKit -framework CFNetwork -framework Foundation -framework UIKit -framework AudioToolbox -framework CoreGraphics -framework Social -framework Accounts -framework AdSupport -framework Twitter -framework CoreLocation -framework MessageUI -framework Security -framework SystemConfiguration -framework CoreFoundation -lz -liconv -u _mono_pmip -u _monotouch_create_managed_ref -u _monotouch_release_managed_ref -u _monotouch_IntPtr_objc_msgSend_IntPtr -u _monotouch_IntPtr_objc_msgSendSuper_IntPtr -u _CloseZStream -u _CreateZStream -u _Flush -u _ReadZStream -u _WriteZStream -lmono-2.0 -lmonotouch-debug -L/Developer/MonoTouch/SDKs/MonoTouch.iphoneos.sdk/usr/lib  -force_load /var/folders/f5/t9d0pqgs10zfnmvbkr298zdr0000gn/T/tmp13b1812.tmp/libShareKit.a -sqlite3.0 "-lsqlite3.0"
collect2: ld terminated with signal 6 [Abort trap: 6]
ld(18617,0x7fff7948e180) malloc: *** error for object 0x7fc5fbcbbdf0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

error MT5201: Native linking failed. Please review user flags provided to gcc: "-lsqlite3.0"
  at MTouch.CompileToNative (System.String user_gcc_flags, System.Collections.Generic.List`1 assemblies, IList`1 inputs) [0x00000] in <filename unknown>:0 
  at MTouch.Main2 (System.String[] args) [0x00000] in <filename unknown>:0 
  at MTouch.Main (System.String[] args) [0x00000] in <filename unknown>:0 


IDE and OS details:

Xamarin Studio
Version 4.0 (build 2003)
Installation UUID: 5ab8a0d5-8e36-4b00-b445-d9c8f08cd214
	Mono 2.10.11 (mono-2-10/2baeee2)
	GTK 2.24.14
	GTK# (
	Package version: 210110000

Apple Developer Tools
Xcode 4.6 (2066)
Build 4H127

Version: (Business Edition)

Not Installed

Xamarin.Mac: Not Installed

Build Information
Git revision: Release ID: 400002003
Build date: 2013-02-20 00:32:59+0000
Xamarin addins: b7a7aff09b352c13ded8a27439fd6d2250361511

Operating System
Mac OS X 10.8.2
Darwin MacBook-Air-Alexander-Kuznetsov.local 12.2.0 Darwin Kernel Version 12.2.0
    Sat Aug 25 00:48:52 PDT 2012
    root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64

Comment 1 Alexander 2013-02-26 08:09:45 UTC
Attachment was too big - sample solution is here:
Comment 2 Jeffrey Stedfast 2013-02-26 14:36:18 UTC
For some reason gcc is crashing when it tries to link for device and I don't know why.

Alexander: currently you are adding the -lsqlite3.0 in both the LinkWith attribute *and* in the "Additional mtouch arguments" in the Project Options. You don't need to do that. I would recommend removing the gcc flags from your Project Options.

Maybe Sebastien will have an idea why gcc is crashing...
Comment 3 Alexander 2013-02-27 05:30:20 UTC
Yes, this sqlite linking was the only suspicious point I saw so I just tried to add LinkerFlags parameter in hope that it would magically help (it didn't). 
It seems, by the way, that LinkerFlags parameter in binding library doesn't make any difference at all - if I leave it and remove flags from main project, linker can't find sqilite lib symbols.
Comment 4 Jeffrey Stedfast 2013-02-27 14:54:48 UTC
I modified your project locally to remove the -lsqlite3.0 from the Project Options and the build used the -lsqlite3.0 directly from the LinkerFlags property just fine.
Comment 5 Jeffrey Stedfast 2013-02-27 14:55:42 UTC
(btw, that's why when you build it, it probably has 2 -lsqlite3.0's - one is from LinkerFlags and one is from Project Options... at least when I first tried building your project, it added -lsqlite3.0 twice)
Comment 6 Alexander 2013-02-28 15:26:01 UTC
You're right, a had a misprint in LinkerFlags.

We just found that workaround from this thread (setting Minimum iOS version to 5.1) is working:

but we can't rollback our whole project to 5.1 :(
Comment 7 Alexander 2013-02-28 17:07:49 UTC
We found solution that seems to work: just removed CoreFoundation from LinkWithAttribute.Frameworks property.
Comment 8 Rolf Bjarne Kvinge [MSFT] 2013-07-22 10:42:53 UTC

*** This bug has been marked as a duplicate of bug 6998 ***