-
Notifications
You must be signed in to change notification settings - Fork 515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Native linking failed, undefined symbol ..." when building in debug mode #17387
Comments
All the updates finished now. The same still happens with |
Could you get a binary build log as explained here: https://github.com/xamarin/xamarin-macios/wiki/Diagnosis#binary-build-logs? Thanks! |
Hi @MichaelRumpler. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
It did hang yesterday. Today I restarted VS and reproduced it after building for 2mins. |
This is a rather interesting and complex problem. Just for reference: the error shows up in the file What I figured out: The reason it fails, is because the Windows build references the netstandard1.3 version of System.Security.Principal.Windows.dll:
while in the Mac build we don't get the reference directly, instead the version shipped with Xamarin.iOS is loaded because:
It's not entirely clear from the build log the reason for this difference in behavior, but it seems the I could spend time diagnosing more, but since this is a legacy Xamarin.iOS project, it's unlikely we'll spend time fixing the issue on our end, in particular because it's likely this is fixed in .NET anyways (note that the System.Diagnostics.EventLog package does not depend on System.Security.Principal.Windows in .NET 6+: https://www.nuget.org/packages/System.Diagnostics.EventLog#dependencies-body-tab). However, I have an idea for a workaround: explicitly reference System.Security.Principal.Windows, and maybe that will make us resolve the correct reference: diff --git a/RoyalMobileApps.XF.iOS/RoyalMobileApps.XF.iOS.csproj b/RoyalMobileApps.XF.iOS/RoyalMobileApps.XF.iOS.csproj
index 25d8644..bdb5f66 100644
--- a/RoyalMobileApps.XF.iOS/RoyalMobileApps.XF.iOS.csproj
+++ b/RoyalMobileApps.XF.iOS/RoyalMobileApps.XF.iOS.csproj
@@ -166,6 +166,7 @@
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
+ <Reference Include="System.Security.Principal.Windows" />^M
<Reference Include="Xamarin.iOS">
<Private>False</Private>
</Reference> Can you try that and see if it works? Another potential workaround is to remove the System.Diagnostics.EventLog package reference, if that's something you can do without. |
Hi @MichaelRumpler. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Nope, that doesn't seem to work. It's still the same error. However, we removed that class and the NuGet reference from the shared project and added it in the Windows app instead. This does the trick. I mainly wanted it to be documented. Maybe you could add a link in the original issue #10884. It doesn't display the reference automatically. Maybe because it's locked. |
I've added a comment on that issue. |
I finally managed to reproduce the errors reported in issue #10884. I couldn't reproduce it in a new project so I had to take my actual app and remove code until it was almost empty. The difference is, that I already get those linker errors when building in debug mode. The linker should not get involved at all in this stage.
Steps to Reproduce
Expected Behavior
It builds successfully.
Actual Behavior
The build fails with "Native linking failed, undefined symbol ...". The missing symbols sound very Windows specific.
If I don't pair VS to a Mac and only build locally on Windows, then it works.
Environment
VS 17.5.0 Preview 2 + 3 with Xamarin.iOS 16.1.1.28, Xcode 14.1 and macOS 13.0.1
(I also updated to VS Preview 4, which wanted to install Xamarin.iOS 16.2.0.2 which refrains working with Xcode 14.1. Xcode 14.2 is downloading now.)
Example Project (If Possible)
In the shared project RoyalLogging somebody added a reference to System.Diagnostics.EventLog and uses classes like
System.Diagnostics.EventLog
. This makes no sense on iOS, but as it is a netstandard2.0 dll, it is totally possible. The code is in the file WindowsEventLogLogger.cs. I don't use that class anywhere in my solution. It is only used on Windows.I also left a reference to Microsoft.AppCenter.Analytics in the repro. If I remove it, then it raises a different error and I was not sure, if it was still the same as in #10884.
Repro_NativeLinker.zip
The text was updated successfully, but these errors were encountered: