Windows MSVC++ .def file helper…
I’m trying to make copying a project and creating a new project as simple as possible with as few changes as possible. So far I’ve got my solution name passed down to name everything. Except of course the .def file. So I made this prebuild script and added it to the project properties:
echo LIBRARY $(TargetFileName) > "$(IntDir)$(TargetName).def"
echo EXPORTS >> "$(IntDir)$(TargetName).def"
echo main >> "$(IntDir)$(TargetName).def"
Then $(IntDir)$(TargetName).def is the .def file needed.
On Wed, Nov 19, 2008 at 11:51 AM, Martin Robinson <
> I’m trying to make copying a project and creating a new project as simple
> as possible with as few changes as possible. So far I’ve got my solution
> name passed down to name everything. Except of course the .def file. So I
> made this prebuild script and added it to the project properties:
You don’t need to use def files at all. For Windows put
__declspec(dllexport) in front of your main function. Typically you’d want
to put this in a macro which has its definition depending on the platform,
so for OSX it would be empty, and for Windows it is set to
To create a new project from an existing one, I delete everything except the
vcproj file, the solution and the sources. Then I rename the source files,
and open vcproj in a text editor to do a find/replace on the old object
name. All that’s left to do then is some find/replace operations on the
copied source files. You can keep the Max dependencies in the same relative
path to your project directory so the includes don’t need any changes.
I’m sure you can all automate this find/replace business. I’ve been too lazy
to look into it, but if someone figures it out it would be nice to know how
So, do we really need
You don’t need dllmain_win.c. The version we include calls DisableThreadLibraryCalls() in DLL_PROCESS_ATTACH. This is an optimization that tells the OS not to bother sending the DLL (external) DLL_THREAD_ATTACH and DLL_THREAD_DETACH messages each time a thread is created/destroyed. Since the max process can have a lot of externals loaded, and most externals don’t do anything with these messages, it seems like a worthwhile optimization.