Trying to build a statically linked binary, getting link error
- Dominant language
- No language data
- Stars
- 4.8k
- Forks
- 6.1k
- Avg merge
- 19h 10m
- Merged PRs (30d)
- 268
Description
### The problem
I was trying to build a statically linked binary that Direct P/Invokes into a static dependency according to an official [doc](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/interop), got `error LNK2001: unresolved external symbol ` while trying to do so. I then referred to an existing working [example](https://github.com/sneusse/aot-static-example), tried to build it but got the same error. I've also tried to run the build command from a Developer Command Prompt for VS, still the same error. Command `where link && where cl` returns two paths pointing to msvc linker and compiler accordingly, so the absence of these is clearly not an issue.
### To Reproduce
On Windows, invoke `build.bat` from https://github.com/sneusse/aot-static-example
---
#### Document Details
⚠ *Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.*
* ID: 741144e9-61bf-4cb7-c93b-fceb1a5eae71
* Version Independent ID: 22954c29-b82c-5e3d-3bf0-0a954641a341
* Content: [Native code interop with Native AOT - .NET](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/interop)
* Content Source: [docs/core/deploying/native-aot/interop.md](https://github.com/dotnet/docs/blob/main/docs/core/deploying/native-aot/interop.md)
* Service: **dotnet-fundamentals**
* GitHub Login: @MichalStrehovsky
* Microsoft Alias: **michals**
Contributor guide
Assessment
This issue has not been assessed yet.