Archived

This topic is now archived and is closed to further replies.

Static or Dynamic library

Recommended Posts

ArnoAtWork    138
Hi, I would like to build a library which could be used static or dynamic(dll). How can I make this one? Thanks a lot. Arno.

Share on other sites
Spudder    385
You could do something like this:
#ifdef BUILD_DLL#define MY_API __declspec(dllexport)#else#define MY_API __stdcall#endifint MY_API SomeFunction(void);

This way if you define the symbol MY_API then all the methods which you have prefixed with MY_API will be exported to the .dll otherwise they will be compiled as ordinary methods.

To create the .lib and .dll you will need two separate projects to build each version but the source code will be the same in both projects, you don't have to make changes to export the methods in the .dll project for example.

[edited by - Spudder on January 17, 2004 8:16:59 AM]