Create DLL (no entry point) from command line using MSVC

I want to use the MSVC compiler to create a DLL file.

The problem is that there is no main entry point in the DLL. It must be a shared DLL used as a plug-in by the application. I can compile it using GCC like this:

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

The DEF file should avoid name manipulation in the plugin export function (this application uses the plugin via this function).

If I try to compile it using MSVC, the linker complains that I need to specify an entry point.

I would like to ask one more question: is there a tool in MS Visual Studio package like GCC "strip" to reduce the size of the EXE file?

+2


source to share


1 answer


While the DLL does not require an entry point, the Microsoft C Runtime requires initialization of the entry point. Is there any reason not to have an empty DllMain?

When building a DLL that uses any of the C runtime libraries to make sure the CRT is properly initialized, either

  • the initialization function should be called DllMain () and the entry point should be specified using the linker option -entry: _DllMainCRTStartup @ 12 - or -

  • the DLL entry point should be explicitly call CRT_INIT () when attaching a process and detaching a process



KB94248

+3


source







All Articles