Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
I have an assembly which is generated using btouch. It contains both ObjectiveC bindings as well as P/Invoke wrappers for some C functions. I then reference the resulting assembly in my main app. If I build for the simulator it works fine, but if I build for the simulator it produces this error:
/Developer/usr/bin/strip: symbols names listed in: /var/folders/9n/30_lyqjj28z3k7ds6_j8z0km0000gn/T/tmp1441f10a.tmp/symbol-file not in: /Users/akemp/Projects/nextgen/R2/Tablets/Dev/Tablets/DataDashboard/bin/iPhone/Release/DataDashboard.app/DataDashboard
Those are the C functions which I wrap with P/Invoke. The difference between the simulator and device builds are the linker behavior settings, which are set to "Don't Link" on the simulator and "SDK only" on the device. If I switch to "Don't Link"for the device it works. I would rather not do that unless I have to, though.
It seems that the linker is having trouble knowing that those particular symbols are called dynamically. Is there a way I can make it recognize C symbols which are called dynamically? Ideally it should recognize the [DllImport] attribute and mark those symbols as reachable.
FYI, I am using -force_load for the static library, so I believe that the native linker is behaving properly, but if there is something else I need to do let me know.
> but if I build for the simulator it produces this error:
but if I build for the *device* it produces this error:
^ right ?
There are two linkers
1. the managed one: which you can control with "Don't link", "Link SDK assemblies only" and "Link all" options
2. the unmanaged (native) one
For the managed linker if there is no (managed) code calls into _VariableManager_[Init|Subscribe|Uninit|Unsubscribe] then the (managed) linker will eliminate them (remove the [DllImport] from the assemblies). In turn it means the symbols won't be "protected" from being stripped out later.
I'm not totally sure what you mean by "called dynamically" but this might confuse the (managed) linker - a bit like reflection can do. In such case you need to add the [Preserve] attribute on each definition. That will instruct the linker to preserve the methods even if it cannot find the code that requires them.
Once the [Preserve] attribute are present you can re-enable the default (for devices) "Link SDK assemblies only".
Please let me know if this solves your issue (or just close the bug if it's ok :-)
It turns out that this was just some misleading errors. I found the right combination of changes to make this work, and it has nothing to do with the Linker Behavior settings.
I changed two things:
1. Use armv7 as the architecture in the app's build. My static lib uses armv7, but the app was using armv6, and so it was ignoring the static lib. Oddly, it didn't tell me it was ignoring it until I tried (out of desperation) adding "-u _VariableManager_Init" to the build line. Then it spit out some warnings that it was ignoring things. Now I get to figure out how to make this work in a debug build (that's another issue).
2. Add a bunch of frameworks that were needed by the static lib.
I could create a bug report for the fact that the linker warnings about ignored static libs were being filtered out unless there were linker errors if you want me to, but I will close this particular "bug" because it's not really a bug.
Thanks for the info. Please fill a bug report about the linking not warning you about the lack of a matching architecture in the static library. That's definitively not something easy to find!