I compiled the following code into a DLL in visual C++ with the "release" configuration

#define MY_FIRST_DLL __declspec(dllexport)

extern "C" MY_FIRST_DLL
int main(void)
{
   return 0;
}

And the size of the DLL was 7 KB.

I created a file called test.cpp and compiled it manually in command-line with the following:

cl /LD test.cpp

And it was 32 KB.

What does the IDE do that allows it to create the 7 KB dll from the same code? And how can I achieve the same result manually (or perhaps a batch file)?

有帮助吗?

解决方案

When you set the 'release' option, the command line to build your code is very different. Visual Studio sets the optimizations settings and other thinks. You can see that command line, in the project configurations: -> C/C++ compiler ( or something like this ) -> command line ( option )

see the picture: enter image description here

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top