docs icon indicating copy to clipboard operation
docs copied to clipboard

Trying to build a statically linked binary, getting link error

Open JackHarckness opened this issue 1 year ago • 2 comments

The problem

I was trying to build a statically linked binary that Direct P/Invokes into a static dependency according to an official doc, got error LNK2001: unresolved external symbol while trying to do so. I then referred to an existing working 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.

JackHarckness avatar Apr 10 '24 08:04 JackHarckness

Actually running build.bat from x64 Native Tools Command Prompt for VS 2022 solved the issue and got comilation going. I guess there is an issue within my specific configuration, maybe something is wrong with PATH. Perhaps we should consider extending the doc, since this is not an obvious solution?

JackHarckness avatar Apr 10 '24 09:04 JackHarckness

Moving this as a doc improvement issue 🤔

nagilson avatar Apr 30 '24 20:04 nagilson