Mingw & SDL_OpenObject

I’m have created my own library that I open at run time using SDL_OpenObject under Linux/gcc and this works well.

I am trying to port the code to MINGW but I am uncertain what format to make the library. Should it be a Windows dll or a MINGW so or something else. I have tried both but SDL_OpenObject refuses to find the library!

Not sure if it is a formatting or pathing issue at this stage.

In addition I have tried to open any of the libraries in /C/MSYS64/MINGW64/LIB and I always get back “Specified module could not be found”.

AFAIK it should work with DLLs (and just those) on Windows.

I doubt that a path like /C/MSYS64/MINGW64/LIB/bla.dll works though - does it work with proper windows paths, starting with “c:\” instead of “/C/” and maybe using backslashes instead of forward slashes?
(Though I think forward slashes should work as well)

I tested that with libcrypto.dll. If I type the full path “C:\Windows\System32\libcrypto.dll” it works fine. But if I do the same for my library and all other in the “C:\MSYS64\MINGW64\lib\libexample.dll” it doesn’t work!

could it be a 32bit vs 64bit problem?
what does SDL_GetError() say?

0x6c84d080 “Failed loading c:\Users\HP\Projects\Documents\OVCC\HardDisk\libharddisk.dll: The specified module could not be found.\r\n”

and you’re sure there’s no typo in the path?

is your application 32bit or 64bit? is the dll the same?

Everything is 64 bit and path checked!

I dragged the error message into a CMD windows and verified with dir …

Have you tried using LoadLibrary() (the WinAPI function) directly? (You’d probably have to #include <windows.h> first)
Like

HMODULE libhandle = LoadLibrary(path);
if(libhandle == NULL) {
  printf("LoadLibrary( \"%s\" ) failed, error code: %d\n", path, GetLastError());
}

Got it!

Found an excellent link on creating dll’s correctly in MINGW.

https://www.transmissionzero.co.uk/computing/advanced-mingw-dll-topics/

My dll is now recognised!