Attempting to compile a 64-bit DLL using mingw-w64

I am trying to compile a 64-bit version of Ada dll using mingw-w64 for use in a C ++ program.

It seems to work because it compiles without errors and loads into 64-bit programs, and I can get the address of the interface functions using GetProcAddress.

However, when you try to call these functions, they break down in unusual places with access violation errors. Looking at the pointers, it looks like they are all 0x00000000 ########, that is, none of them have bits outside the usual 32-bit set of addresses.

Looking at the ad files created by gnatbind, I also find:

  type Version_32 is mod 2 ** 32;
   u00001 : constant Version_32 := 16#65712768#;

This, it seems to me, indicates that even if it compiles the parts of the dll in the 64-bit version (it is enough to deceive the compiler and the program, assuming that the dll is 64-bit enough to load it), the main implementation is still coming out as 32 -bit. I assume that the cause of access errors is access to 32-bit memory addresses when the program expects 64-bit addressing.

How can I get mingw-w64 to actually compile and bind the dll in 64-bit state?

+4
source share
1 answer

Make sure you call adainit and adafinal dll. Or you need to use gnatbind -a . In GPR, it looks like this:

   package Binder is
      for Default_Switches ("Ada") use
        ("-a");         -- call adainit from DllMain
   end Binder;

MinGW64 MSYS2. . TDM-GCC libgnarl, - .

0

All Articles