Bug 33755 - iOS Link Native Library using Visual Studio
Summary: iOS Link Native Library using Visual Studio
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: unspecified
Hardware: PC Windows
: Normal normal
Target Milestone: 4.2.0 (C8)
Assignee: Bugzilla
Depends on:
Reported: 2015-09-07 22:54 UTC by Anubhav Ranjan
Modified: 2016-06-10 17:26 UTC (History)
6 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 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 Anubhav Ranjan 2015-09-07 22:54:54 UTC
One of our customers is facing issues when trying to Link Native Library using Visual Studio

Sample Project:

In our project we have an Externals folder where we like to keep all our external libraries.
We then add these libraries as links in Visual Studio. For images / resources this works which I assume is because there is a build action associated with the linked files.

For native *.a files on iOS, while they copy when developing on the mac, they do not copy to the mac when building from Visual Studio on Windows (through the build host).
A work-around is to add the file into the directory directly but we would prefer the link option.

I've attached a sample app with one of our native c libraries demonstrating the issue:

Error 4 Native linking error: file not found: /Users/kea-build/Library/Caches/Xamarin/mtbs/builds/Phoneword_iOS/ef2b80107ff7ccf001a338c4013e708e/lib/libcsiblib.a C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets 501 3 Phoneword_iOS
Error 3 Native linking error: warning: directory not found for option '-L/Users/kea-build/Library/Caches/Xamarin/mtbs/builds/Phoneword_iOS/ef2b80107ff7ccf001a338c4013e708e/lib' C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets 501 3 Phoneword_iOS

And sure enough there is no LibLink/libcsiblib.a on the mac.

Please note when adding the library directly you will see this error:
Native linking failed, undefined symbol: _CartToGeog. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets 501 3 Phoneword_iOS

This means that it has found the native c library. I just haven't provided all of our code. Our issue is that it is not copying to the mac, not the undefined symbol.

Note: I've included a libLink and a libActual folder. The libLink contains a link to the native library (won't copy to mac). libActual has the file directly added to the folder and does copy.

#Version Info:

Xamarin Studio 5.9.5 (build 10)
Xamarin iOS

Visual Studio 12.0.40629.00 (Update 5).
Visual Studio Xamarin Extension 3.11.837
Visual Studio Xamarin.iOS 8.10.4
Xamarin Studio 5.9.5 (build 10)
Comment 2 Kea Build 2015-09-07 23:28:18 UTC
As the original reporter I'll amend the above post.
There is a folder lib and libActual. (not liblink)
lib contains a file added as a link.
libActual has a file added into the project.
The library in lib nor the folder gets copied to the mac building with VS.

I would expect to find the linked file in {guid}/bin/iPhone/debug/lib/libcsiblib.a.

Building on the Mac using Xamarin Studio the linked file is found in the output directory/bin/iPhone/debug/lib/libcsiblib.a.

Comment 4 Parmendra Kumar 2016-06-10 17:26:21 UTC
As per comment #3 marking this issue as Verified Fixed.