[SOLVED]Problem using third party libraries


I have some problems adding/using third party libraries.

What i am trying to do :

Using “MySql Connector C++” library in UE4 as a plugin to use MySql databases in my projects (MySQL :: MySQL Connector/C++ 8.0 Developer Guide).

First attempt using static libs :

I first tried to include the static Connector library in a plugin which is using boost library, that’s where the first problem appeared.
Boost library is using some preprocessor definitions like #define GNUC which doesn’t exist because UE is not using preprocessor macro (i can’t find the link where i read that sorry), i’m not sure what it means or implies exactly and i didn’t manage to find any workaround for that problem.

Second attempt using Dll :

Then i tried using my own Dll to avoid the compilation by the engine of the macros (maybe it’s a mistake because i dont understand fully these mechanics).
So i **first **tried to load my own dll copying the example given by the engine when creating a third library plugin, it’s working the dll is loaded and i can use the functions.

Then for my **second **try i added a function to my Dll using the Connector/boost libraries (i’m using them as static libraries to create my dll maybe it’s where i’m wrong) then when i try to load the Dll (GetHandleDll) it doesn’t work saying in the output :

‘UE4Editor.exe’ (Win32) : Loaded ‘F:\Projects\DllUETest\Plugins\TPDllTest\Binaries\ThirdParty\TPDllTestLibrary\Win64\TestDllConnector.dll’. Symbols loaded.
‘UE4Editor.exe’ (Win32) : Unloaded ‘F:\Projects\DllUETest\Plugins\TPDllTest\Binaries\ThirdParty\TPDllTestLibrary\Win64\TestDllConnector.dll’
[2019.11.12-18.54.22:696] 0]LogWindows: Failed to load ‘…/…/…/…/…/…/Projects/DllUETest/Plugins/TPDllTest/Binaries/ThirdParty/TPDllTestLibrary/Win64/TestDllConnector.dll’ (GetLastError=126)

The paths/loactions are good since i just replaced the new Dll from the first attempt and the “GetLastError=126” means that the module wasn’t found (from…-codes–0-499-).
I also found that this loading/unloading could come from the response of the Dllmain of my Dll but i’m not using any main in either attempt (…i-loadlibraryw)

Third attempt :

I tried two plugins using MySql which are working but i can’t access the sources. One author told me how he did it with some other lib but i would like to make the C++ lib work so i can modify and make my tools directly.

Finally :

1- Is there something i didn’t try?
2- Did i do something wrong somewhere in my attempts (a workaround for the preprocessor problems or a mistake in my Dll setup?)

Thanks for reading, i didn’t link any code because i don’t know what can be relevant.

Sorry if it’s not the right section for this topic.

Libs can be configured for target compiler and they can get rid of invalid content hopefully producing a solution you can work with in vs. Steam’s online subsystem is one example of many where you can see extensive usage of 3rd party libs. Tho it may take some time figuring out this way, but at least you get plenty of examples. I wouldn’t risk statically linking a library that license may not compatible with the restrictions in unreal’s eula. You’re probably better off focusing on dynamic linking instead.

Thanks for the answer !

Just to be sure to understand when you are talking about libs being configured for compiler and steam’s online subsystem example you are talking about static linking right ?

So i should focus on dynamic linking and try to figure out why my Dll using another lib isn’t loading ?

**Edit: **I think i solved my problem with dll for good i just forgot to import the dll that my own dll needed (i thought my dll packed all it needed from the other ones but it seems it’s just calling the other dll’s it needs, as i said i’m not really used and skilled about that stuff…).
Anyway thanks for the help :slight_smile: