Difference between “dynamic-link library with exports” and “dynamic-link library” in Visual Studio

TL;DR: “with exports” means the project starts with some example exports added. You’ll need exports, so why not let it insert some boilerplate code for you? Less chance of typos. Use “dynamic-link library” instead of “dynamic-link library with exports” if you want to add ‘__declspec’ to things yourself.

So you want to create a DLL in Visual Studio. You’re vaguely aware of how a DLL works, but the options provided to you are still unclear:

Assuming you want a plain old DLL (that has existed for the last 25+ years), you’re going to want one of the top 2 options.

The major difference between them is, “with exports” adds some defines:

#define DLL1_API __declspec(dllexport)
#define DLL1_API __declspec(dllimport)

And it adds some example exports, so you can see how they work:

// This is an example of an exported variable
DLL1_API int nDll1=0;

// This is an example of an exported function.
DLL1_API int fnDll1(void)
{
    return 0;
}

// This is the constructor of a class that has been exported.
CDll1::CDll1()
{
    return;
}

In theory, you can compile this DLL and test it out immediately.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.