How to include a dynamic library into a binary module?


We are talking about gm_bass. I see in private project that binary modules bass.dll, bassmidi.dll, tags.dll not located with the file hl2.exe.
They were located “lua\includes\modules” which is very convenient.

How can this be realized?

And according to tradition - sorry for bad english :slight_smile:

I already tried to load the dlls from else where with, but couldn’t figure out how to do this. The project you are talking about is gmodtower I guess.

Yes, I talked about gmodtower. They found a way, and we should too …

May be they include bass.dll and other, like a gm_bass include in lua?

Maybe they link them dinamically. By this I mean, no usage of lib files, just getting the address of the functions needed from the modules. Or, they add a search path for the Win32 API to be able to find the modules.

Adding search paths doesn’t seem to work so far I tried.

The bass source code can be found here:

I don’t understand why you’re rating him dumb…if he want’s to package both the modules in 1, then why not just compile both of them into 1 module.

That’s not what he wants. He wants to be able to place the required binaries (Awesomium, Bass, etc) on the same place as the modules.

How did you try that? The whole process.

And how are you going to compile something (bass.dll, bassmidi.dll, etc.) to an module without the source code?

You don’t need to compile. You can include those binaries into another binary by making them resources. Though, it’s a rather complicated process to later load those modules into memory and get their functions addresses (this last step is the only possible way, I believe, to be able to use these resource’d binaries).

As I asked how to load the DLLs from elsewhere I got this answer.
The poster wrote that I should use SetDllDirectory(LPCTSTR lpPathName);
And of course the it doesn’t like char strings to I had to something with L(“pathname”), which is supposed to turn those normal strings to LPCTSTRs.
To keep everything simple I tried: SetDllDirectory(L(“bass”)) and to load the bass stuff from bass relative to the hl2.exe. I entered the function on the top of the int Start( ) function.

If you add search paths from the module but are still linking with the BASS library file, it won’t work. Because of the order of the actions. Firstly, you require the module. Secondly, it will search for the required binaries. It won’t find them. If it did find them, then it would add that search path. I believe this is the order.