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.
a source to share
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.
a source to share
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.
a source to share
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()
{
}
a source to share