Skip to main content
GameDev.net gamedev.net
🔒 Locked

c++ visual studio - how to create .def file

Started by turlisk Apr 29, 2010 at 5:49 PM 0 replies 40k views
Original Post
turlisk
turlisk
I'm working on a project in visual studio and I'm creating a dll project and it tells me to add a .def file, I've been doing some research and unable to locate how to create this .def file. I'm using visual studio 2008, any help would be great. thanks.
Drew_Benton
Drew_Benton
If you need to create a DEF file for your DLL by hand:

1. In the folder where your project file (.vcproj) is, create a new text file.

2. Rename it to "outputname.def", where "outputname" is the name of your project's output. By default, this is the name of the project, see Step 4 for clarifications.

3. In Visual Studio, go to Project->Properties. Go to Configuration Properties->Linker->Input and enter the name of the DEF you just created into the field named Module Definition File.

4. Repeat steps 1 - 3 for each configuration that outputs a different named DLL. I.e. my Debug configuration makes output_d.dll, so I need an output_d.def for Debug along with an output.def for Release.

5. Open all of the DEF files in your current Visual Studio editor. The format for the DEF is easy:
LIBRARY outputnameEXPORTS	Function1 @1	Function2


Replace "outputname" with the name of the configuration output. As mentioned in step 4, this could be output in output.def and output_d in output_d.def.

List all of the functions you are exporting. Those functions need to be correctly exported using the correct syntax in your source files. You can manually assign an ordinal by using the @number syntax. Alternatively, you can leave it assigned automatically by not having it.

That's all there is to it. Make sure to Build->Rebuild Solution afterwards. Use Dependency Walker to verify your DLL is correctly exporting your functions with the expected names.

There is more information on this topic here: Exporting from a DLL Using DEF Files . Good luck!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.