Stripping VS 2008 Win32 DLL into one file

I have a VS generated C ++ Win32 DLL project. It has the following files:

stdafx.h targetver.h myProject.h dllmain.cpp myProject.cpp stdafx.cpp

I can remove targetver.h and merge dllmain.cpp into myProject.cpp. What else can I do to get the simplest file structure, preferably a single file. I need to dynamically emit this code file and embed it in a Win32 DLL.

0


a source to share


5 answers


If you want a minimalist file structure, you can simply create the files yourself. Run an empty project or delete all files. Heck, just create a folder, write main.cpp and compile it from the command line with cl .

Several IDEs do try to minify the files as you are trying, but when building the project, you can shorten a bit: stdafx. [h, cpp] are for precompiled headers that you can turn off when building the project.



However, I really don't see any value in minimizing the amount of source code in a compiled language project - it won't have a significant impact on the number of output files / dlls and, properly used, using more files only helps in the clarity of the code.

+1


a source


In addition to what Andy said, you can combine header myProject

files and implementation files as well with dllmain.cpp

. But why not just save those files and create a vsproj file at runtime?



+1


a source


Or you can just create an empty project.

+1


a source


IIRC, myProject.h

and myProject.cpp

both contain an example of an exported class. You can delete them easily.

stdafx.cpp

and stdafx.h

are used for the standard precompiled header file. If you disable the option that requires a precompiled header, then these files will not be needed either.

0


a source


You can # include your generated file in an existing multi-file project. This way you can have a complex project wrapper and only emit something less like a simple function.

For instance:

#include <system_stuff>

void main()
{
   Go();
}

#include "generated_file_that_has_method_go.cpp"

void other_code()
{
}

      

0


a source







All Articles