Reference a GNU C (POSIX) DLL built in GCC against Cygwin, from C#/NET

后端 未结 5 1908
闹比i
闹比i 2020-12-05 20:52

Here is what I want: I have a huge legacy C/C++ codebase written for POSIX, including some very POSIX specific stuff like pthreads. This can be compiled on Cygwin/GCC and ru

5条回答
  •  隐瞒了意图╮
    2020-12-05 21:01

    The code as written won't work, the exported function name is decorated by the C++ compiler and no longer resembles "hello". You'd normally declare the function extern "C" to suppress the decoration.

    But, you haven't gotten that far yet. The LoadLibrary() call is failing with Windows error 998, ERROR_NOACCESS, "Invalid access to memory location". This most typically happens when the DllMain() entrypoint in one of the DLLs you have a dependency on bombs with an AccessViolation hardware exception. This should be visible in the debugger (Output window in Visual Studio), you should see a "First chance exception" with exception code 0xc0000005.

    This is probably going to be unpleasant to diagnose, you've got several DLLs that are candidates and whose debugging symbols probably are a poor match for the debugger you use. Try to isolate this by writing a small test program in C that calls LoadLibrary. Configure the debugger to stop on the first chance exception. In Visual Studio you'd do this with Debug + Exceptions, Thrown checkbox. Good luck with it!

提交回复
热议问题