Debugging a .DLL

Started by
5 comments, last by RegularKid 16 years, 8 months ago
Ok, here's my situation: 1. I've got an executable that I made and it loads in .DLL's from a folder \AI in the same directory as itself. It also loads some other files ( art / sound ). This is not the project, just the straight release executable. c:\GAME\Game.exe c:\GAME\AI\MyDLL.dll c:\GAME\ART\Art.tga c:\GAME\SOUND\Sound.wav 2. I've got a project somewhere else where I'm actually creating the .DLL to put inside the \AI folder. When I compile in DEBUG mode, my newly created .DLL gets put in MyDLLProject\debug\MyDLL.dll. C:\MyDLLProject\debug\MyDLL.dll Ok, so I want to debug MyDLL.dll. How would I go about doing this? If I had the GAME project, I would simply open it up inside Visual Studio and copy over the newly created MyDLL.dll into the c:\GAME\AI\ folder and then step into the DLL through GAME project. However, since I don't have the GAME project ( I only have the final release executable ), I need to be able to debug through the MyDLL project. I can specify through the project properties to use the executable: "c:\GAME\Game.exe" and then I set the working directory to "c:\GAME". However, this doesn't seem to work correctly. How would I do this? I need to debug my DLL but yet I can't move my entire DLL project into the GAME directory in order for the DLL to be in the correct place. The reason that I need this to work without using the GAME project, is because I want to distribute the game to other people and allow them to create their own .DLL's for the AI. Obviously, at that point they will NOT have the GAME project, but just the release executable. Any help would be great! Thanks!
Advertisement
If you don't need to debug in the first parts you can always attach to a running DLL.

Choose Debug->Processes, choose the game from your list and press attach. This should allow you to debug the DLL (you need to copy the debug DLL to the game folder of course).

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Ok, I'll give it a try! Thanks :)
You can also change the output directory in the linker settings, so it'll output to c:\GAME\AI\MyDLL.dll, and then specify the game exe file for the process to debug when the compile finishes (You may have to tinker with the working directory setting in the project settings to get this to work).
Create a solution that has the DLL project and the EXE project. The EXE can be set as the primary project. Then, just debug like normal. You'll be able to set breakpoints in the DLL code, etc.
I also export the debug dll as dllname_d.dll and the release as dllname.dll. In the code, if the game/whatever is using the .dll is using DEBUG define it loads the _d.dll one otherwise the release. Makes life easier too.

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

Thanks guys! Attach to process did the trick :)

This topic is closed to new replies.

Advertisement