-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
An error occurred when linking a static library ".lib" compiled using NativeAOT with a C++ project. #96298
Comments
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
Static linking requires additional runtime libraries to be linked as well. You can find the list of all required libraries by publishing the project as shared library (/p:NativeLib=Shared) with detailed verbosity (-v d), and looking at the output generated by the LinkNative target. We have #70277 opened on improving this experience. Duplicate of #70277 . |
I get the error: LNK1241 Cooler-Native.lib resource file(Cooler-Native.obj) already specified. Here are all the dependencies: |
This is known issue in .NET 8 - #95100 (comment) has workaround. |
Everything works. Thank you. But there was another problem. When adding #include iostream, compilation errors appear. Without using this "#include", compilation completes without errors. |
Sorry. I have solved the problem. I set the "Multithreaded /MT" setting in "code generation" and added "#pragma comment(lib, "libcmt.lib")". |
Compiled NativeAOT libraries:
The C# method before compiling to Native AOT:
Errors when linking the ".lib" file to my CPP project:
The text was updated successfully, but these errors were encountered: