❔ DllImport From C Library
I have compiled a C library to a DLL and am trying to use some of the functions from this library in a C# project.
C#:
C:
This exception occurs when either of the above functions are called:
I don't know if my DllImport signatures are correct, or if there is a problem with the way I have compiled the C library - I have tried using dumpbin and various DLL explorer tools to see which symbols are available but nothing ever appears under the module I am targeting.
9 Replies
Exporting from a DLL Using __declspec(dllexport)
Learn more about: Exporting from a DLL Using __declspec(dllexport)
the library is pure C
I have a wrapper for SDL that works the same way without needing this syntax
and adding in the
__declspec(dllexport)
syntax causes the project not to buildthat syntax is cpp
the library is a single C
.h
file<:PES_SadShrug:646092743378206760> thats what i do
it works in C headers?
I just don't understand why anything is needed if it is just a C library
I thought the point of headers was to expose functions
i dont know much about it myself but i just know how to write a simple c/c++ dll for my c#
you are definitely right, after some more reading it looks like the
__declspec
is required because I am not just compiling c, I am compiling c to a DLL and windows always needs extra steps
the only point of confusion for me now is why I get a ton of unresolved reference external symbol
errors as soon as I mark any symbols to be exported
I have determined that this error was because I didn't add the export flag to all symbolsWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.