-
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
LNK2038 mismatch detected in NativeAOT #85517
Comments
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsDescriptionI build the C# ObjectArx library using NativeAOT for Cad programs like C++, but the library needs two export APIs "ACRXEntryPoint" and "acrxGetApiVersion". Reproduction Stepsin c++ uses #if !defined(_WIN64) && !defined (_AC64)
#pragma comment(linker, "/export:_acrxGetApiVersion,PRIVATE")
#else
#pragma comment(linker, "/export:acrxGetApiVersion,PRIVATE")
#endif
I want to make it like C++ in C# [DllImport("rxapi", EntryPoint = "acrxGetApiVersionImpl", CallingConvention = CallingConvention.Cdecl)]
private static extern ulong acrxGetApiVersionImpl();
[UnmanagedCallersOnly(EntryPoint = "acrxGetApiVersion")]
public static ulong acrxGetApiVersion()
{
return acrxGetApiVersionImpl();
} Expected behaviorit should be build successfully. Actual behavior
Regression?No response Known WorkaroundsNo response Configurationi use .NET 7. Other informationNo response
|
The pre-built .NET runtime libraries that are included in native AOT package are built as "static link" (https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=msvc-170#c-standard-library-stl-lib-files). The error is caused by ObjectArx library built as "dynamic link" that leads to the mismatch. Are you able to rebuild the ObjectArx library as "static link"? If you are using Visual Studio, set Properties / C/C++ / CodeGeneration / RuntimeLibrary to "Multi-threaded (/MT)" in your project file properties. |
there is no source code for ObjectArx. |
We do not have a great solution for this today. The potential workarounds that I can think of are:
#83611 tracks adding an option for compiling the unmanaged runtime with custom C++ compiler options that would help here. |
there is no DLL for
That solution is only available. I hope we get a great solution in the future. |
You can build it yourself.
+1. Resolving as duplicate of #83611 |
I hope can build rxapi but there is no source code for rxapi. it's just headers and static library. |
You can build it from the static library:
|
I understand, thanks. |
Description
I build the C# ObjectArx library using NativeAOT for Cad programs like C++, but the library needs two export APIs "ACRXEntryPoint" and "acrxGetApiVersion".
Reproduction Steps
in c++ uses
I want to make it like C++ in C#
Expected behavior
it should be build successfully.
Actual behavior
Regression?
No response
Known Workarounds
No response
Configuration
i use .NET 7.
Windows 11 X64.
Other information
No response
The text was updated successfully, but these errors were encountered: