Sign in to follow this  

Static library to DLL

Recommended Posts

Hello everyone. I do not know if I'm on the correct forum, but here it goes... I would like to transform a static library in a Dynamic Link Library (DLL). The library in question is SOIL (Simple Opengl Image Loader, <- take a look) and it's very userful for game makers who don't want to "rebuild the wheel". The reason for doing this is to get a smaller bynarie. (I'm working with OpenGL/Win32/MingW+Devcpp). So, whats the correct way for doing this? Thankyou in advance!

Share this post

Link to post
Share on other sites
First off, libSOIL.a is 36KB - that's tiny! Also, you'd most likely need to distribute the DLL with your application to end users, meaning there's no decreased size benefit to be had in that regard. Are you sure it's worth changing it to a DLL in the first place?

That said, SOIL's source code is released as public domain, so you could just use the usual method of creating a DLL: #define a macro that's either __declspec(dllimport) or __declspec(dllexport) dependent on whether you're using or building the DLL, and then slap that on the functions in SOIL.h. Check out this guide.

However, look further down that page and see:
Building and using a DLL without the dllexport/dllimport attibutes
If you pass the -no-undefined and --enable-runtime-pseudo-reloc options to the linker, you don't have to add dllimport or dllexport attributes to the source code that the DLL is made with; all functions are imported/exported automatically by default, just like in unices.

So perhaps do a normal build of SOIL, but pass those options to the linker (probably still along with --out-implib,libSOIL_dll.a). You'd then get your static library for linking implicitly, and the SOIL DLL.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this