Jump to content
  • Advertisement
Sign in to follow this  

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

This topic is 3124 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post

Link to post
Share on other sites
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 outputname
Function1 @1

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!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!