Hi, @mc
Use extern "C"
.
__declspec(dllimport)
is not needed when loading static lib.
Currently , there are still a series of problems when using static libraries, so it is better to use dynamic libraries.
https://github.com/dotnet/runtime/issues/96298
Improve static library publishing
Also check the doc:
https://github.com/dotnet/samples/blob/main/core/nativeaot/NativeLibrary/README.md
Warning
It's preferred to build shared libraries than static libraries:
All code in the loadable module must be compiled with C/C++ compiler version and options that are compatible with native AOT static libraries.
It's also not possible to mix multiple native AOT compiled static libraries within the same loadable module.
These problems don't exist when you build a shared library.
Best regards,
Minxin Yu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.