-
Notifications
You must be signed in to change notification settings - Fork 149
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
The generated .cs file doesn't work (Unhandled exception. System.EntryPointNotFoundException) #533
Comments
When using PInvoke to call a class implemented in C++, it's important to note that the same C++ class method may have different decorated names in x86 and x64 environments. This means you'll need two separate PInvoke declarations for the same method, each targeting x86 and x64 platforms respectively, and then you'll need to manually determine which version to call in your code. |
ClangSharpPInvokeGenerator also provides the following options:
|
I just need x64 modules, nothing else, I tried using the -m64 flag and I still get the same error. |
You can use this tool to inspect the exposed functions/methods in the C++ DLL. Make sure to check the option to leave the decorations alone. What is the target architecture of your C# project? Is it AnyCPU or x64? |
In general binding against C++ is error prone and undesirable due to having an unstable ABI and no standard for exports across platforms/architectures. Its typically recommended to have a C wrapper over your C++ and then bind against the C wrapper instead. ClangSharp does get the mangled name directly from Clang however does not work "perfectly" for cross compilation and so simplify specifying |
I have the intention to generate bindings for a certain library, so in order to get used to it I did my own addition and subtraction C++ library.
Windows 11 23H2 (Build 22631.3235)
ClangSharpPInvokeGenerator 17.0.1
JetBrains Rider 2023.3.3
sumarrestar.h
sumarrestar.cpp
I would ideally like to avoid any changes to the original C++ code or at least they should be as minimal as possible.
Compilation settings:
The command line I used to generate it:
The generated .cs file:
The error I'm getting from the IDE:
Unhandled exception. System.EntryPointNotFoundException: Unable to find an entry point named '?sumar@SumarRestar@@SAHHH@Z' in DLL 'SumarRestar.dll'.
The text was updated successfully, but these errors were encountered: