Skip to content
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

Clarify that NativeLibrary can be used for transitive dependencies #42815

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sweemer
Copy link

@sweemer sweemer commented Oct 3, 2024

I have added the following two clarifications:

  1. NativeLibrary can be used more than once. Originally I thought that it can only be used for the library specified in DirectPInvoke, but after some time I realized it can be used for transitive dependencies as well. My change makes this more clear.
  2. Added /path/to to make it clear that paths are accepted and that the file does not need to be manually moved to the project output directory in order to be found.

Internal previews

📄 File 🔗 Preview link
docs/core/deploying/native-aot/interop.md docs/core/deploying/native-aot/interop

@sweemer sweemer requested review from adegeo and a team as code owners October 3, 2024 09:32
@dotnetrepoman dotnetrepoman bot added this to the October 2024 milestone Oct 3, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates PR is created by someone from the .NET community. label Oct 3, 2024
@gewarren gewarren requested a review from agocke April 3, 2025 20:04
@agocke
Copy link
Member

agocke commented Apr 3, 2025

Also @MichalStrehovsky

Comment on lines -59 to +63
<NativeLibrary Include="Dependency.lib" Condition="$(RuntimeIdentifier.StartsWith('win'))" />
<NativeLibrary Include="Dependency.a" Condition="!$(RuntimeIdentifier.StartsWith('win'))" />
<NativeLibrary Include="/path/to/Dependency.lib" Condition="$(RuntimeIdentifier.StartsWith('win'))" />
<NativeLibrary Include="/path/to/Dependency.a" Condition="!$(RuntimeIdentifier.StartsWith('win'))" />
<!-- Specify an additional library to link against, if necessary -->
<NativeLibrary Include="/path/to/TransitiveDependency.lib" Condition="$(RuntimeIdentifier.StartsWith('win'))" />
<NativeLibrary Include="/path/to/TransitiveDependency.a" Condition="!$(RuntimeIdentifier.StartsWith('win'))" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave this section as is and add a note/remarks after. Something to the tune of:

  • If the native library has a dependency on other static libraries, the transitive dependencies need to be provided as NativeLibrary items as well. Native linker will fail with a message with missing symbols if the transitive dependencies are not provided.
  • Platform conventions are followed when it comes to the format of NativeLibrary entries. The underlying native linker may search standard library paths or allow rooted file paths.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. Should I make the requested changes, or would it be better for someone from Microsoft to provide the correct wording?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sweemer You can make the suggested changes. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Indicates PR is created by someone from the .NET community. dotnet-fundamentals/svc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants