views:

226

answers:

1

Hi, I want to use MSVC compiler to build a DLL file.

The problem is that the DLL doesn't have a main entry point. It's supposed to be a shared DLL used as a plug-in by an application. I can compile it using GCC this way:

gcc -c plugin.c gcc -shared -o plugin.dll plugin.o interface.def

The DEF file is to evade name mangling in a function export of the plug-in (it is the way the application use the plugin, through that function).

If I try to compile it using MSVC the linker complains that the entry point has to be defined.

I would like to ask another question, is there a tool in the MS Visual Studio suite like the GCC "strip" to reduce file size of EXE's?

+2  A: 

While DLLs do not require an entry point, the Microsoft C runtime requires an entry point to initialize itself. Is there a reason not to have an empty DllMain?

When building a DLL which uses any of the C Run-time libraries, in order to ensure that the CRT is properly initialized, either

  1. the initialization function must be named DllMain() and the entry point must be specified with the linker option -entry:_DllMainCRTStartup@12 - or -

  2. the DLL's entry point must explicitly call CRT_INIT() on process attach and process detach

KB94248

FigBug
Thanks, no there was no reason for that, the sample plugin does not hava a main entry point that's why I had it that way. Anyway I found that adding the /DLL option to the linker allows you to do what I wanted, maybe you could add it to the answer to make it more complete. Thanks for everything!
Shantia