Mingw & SDL_OpenObject


#1

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.


#2

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”.


#3

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)


#4

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!


#5

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


#6

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


#7

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

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


#8

Everything is 64 bit and path checked!

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


#9

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());
}

#10

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!