Loading DLL dependencies from memory

Hi all,

I’m working on a projet that use a both AGG and Cairo graphics libraries with our coolest API : JUCE.

I’ve write some LowLevelContext for my application. One is a AGG context that provide finest vectorial drawing on screen. One is using Cairo surfaces for some other export stuff like PDF.

AGG code is template based. So hard to work with, but really easy to include to our project (no dependencies). About Cairo, C based, but Cairomm provide C++ wrapper, very simple API. No problem for using both in my application.

The problem come at the compilation level. Cairo is MinGW based and can’t be (directly) compiled with Visual Studio. For the moment, the only way i’ve found to use it is to compil using a dynamic library (3 to be exact, libcairo.dll, libpng.dll, zlib.dll). But don’t like that. At the level of the application, I prefer using static library and don’t have a “trash” directory with many dll.

I’ve search over the web for solution. But don’t find anything. So, if someone have information for me at this level, don’t hesitate to reply please.

My question come. If i can’t compil my application with static library. Do you think it’s possible to “fake” by include the dlls as ressources (BinaryBuilder) and load the library at application starting ? The Process class of Juce provide 3 methods to do a dynamic loading, but calling the loading by a path or filename. Maybe i’m confused about the process of the starting application, maybe the executable need to link before application have hand. Don’t know.

Someone ? Thank you by advance,

I’m no expert on this kind of stuff, but I don’t believe that’s possible. DLLs are portable executables just like .exes, (in fact the main difference between a dll and an exe is the presence or otherwise of a main() function).

This means that it is possible for an executable to import itself as a dll, but equally it means that the address table will already be in use. For that reason I don’t think it’s possible to combine the address tables of all three DLLs and your executable.

This will do what you need, but it is very expensive:


[edit] I’m assuming you’ve already considered simply having the exe write the dll as a binary file at run time then linking to it dynamically. I personally don’t like this approach as it is wasteful, increases start up times, and still potentially leaves clutter, unless your shutdown code is very good about cleaning up behind itself. That said, it is an option.

Thank you for your answer valley.

DLL2Lib is effectively the tool that i need but the price is too expensive for me. More, the problem is only on Windows distribution and not critical for me it’s just a question of files hidden or not.

I’ve check the juce API and it’s not possible directly to do what I want.

I’ve found the solution to compil cairo in static and be include in my executable. So if someone is interested by the libs (debug/release and the headers) don’t hesitate to contact me.


I’m interested in trying your LowLevelSoftwareRenderer that uses agg