Windows MSVC++ .def file helper…

Nov 19, 2008 at 10:51am

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.

#40924
Nov 19, 2008 at 12:27pm

On Wed, Nov 19, 2008 at 11:51 AM, Martin Robinson <
martinrobinson_mail@yahoo.co.uk> wrote:

>
> 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:
>
>
Hi Martin,

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
__declspec(dllexport).

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
it’s done.

Thijs

#145264
Nov 20, 2008 at 7:37am

So, do we really need

dllmain_win.c

?

#145265
Nov 20, 2008 at 12:12pm

On Thu, Nov 20, 2008 at 8:37 AM, Martin Robinson <
martinrobinson_mail@yahoo.co.uk> wrote:

>
> So, do we really need
>
> dllmain_win.c
>

I’m not sure, but all of my externals so far seem to have been fine without
it. Maybe its obsolete now?

Thijs

#145266
Dec 4, 2008 at 3:21pm

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.

Rob

#145267

You must be logged in to reply to this topic.