Bug 45240 - Native linking error with binding project when Entitlements are used
Summary: Native linking error with binding project when Entitlements are used
Alias: None
Product: iOS
Classification: Xamarin
Component: MSBuild ()
Version: XI 10.0 (iOS10)
Hardware: PC Windows
: Normal normal
Target Milestone: (C9)
Assignee: Jeffrey Stedfast
Depends on:
Reported: 2016-10-10 14:29 UTC by John Miller [MSFT]
Modified: 2017-02-21 21:20 UTC (History)
7 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 John Miller [MSFT] 2016-10-10 14:29:50 UTC

Attached are two build logs from the same solution. The only difference is supposed to be the use of an Entitlements file in the iOS project. It's unclear why the project produces native linking errors with a referenced binding project after adding an Entitlements file. 

**Actual Results**:

In the log that uses the Entitlements file, I see lots of errors like:

 Undefined symbols for architecture i386: (TaskId:512)
1    "std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>

**Expected Results**:

No errors. However, it does seem there could be an issue with the bombgar reference not being built for i386. I am just not sure why it's only surfacing when using Entitlements. 

**Build Date & Platform**:

Comment 2 Sebastien Pouliot 2016-10-12 14:23:33 UTC
The Entitlements.xcent is given to the (native) linker thru mtouch's `--gcc_flags` but they are not merged into a single argument, e.g.

--gcc_flags=-stdlib=libstdc++ -v -v -v -v --gcc_flags "-Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/dougstephens/Library/Caches/Xamarin/mtbs/builds/Cortana.Container.MT/de95adc32953f62af35a8d808ab53983/obj/iPhoneSimulator/Debug/Entitlements.xcent"

So the call to `clang` only has the last one (the entitlement bits) and miss the customer's linker flags which specify the C++ library to be used. That result in the native linker error.
Comment 3 Jeffrey Stedfast 2016-10-12 18:34:22 UTC
Simple fix:

Change your Mtouch Extra Arguments value from "--gcc_flags=-stdlib=libstdc++ -v -v -v -v" to "--gcc_flags -stdlib=libstdc++ -v -v -v -v" and things will work.

(i.e. the current MSBuild logic does not handle "--gcc_flags=....", it only works if you do not use the '='.
Comment 4 Jeffrey Stedfast 2016-10-12 18:51:58 UTC
Comment 8 Shruti 2017-02-07 06:11:02 UTC
@Jeffrey , It would be great help if you have a look to comment6 and respond with your inputs.
Comment 9 GouriKumari 2017-02-21 21:20:13 UTC
Verified this issue with an iOS project referring to a  bindings project and I couldn't reproduce this issue, hence I am marking this issue as verified fixed. 

Build Log: https://gist.github.com/GouriKumari/0b56c64b42a10bbb402a22ee809147d4

## Test Env: