PD externals in Visual Studio 2017

  1. Create a new project (New>Project… from file menu)
  2. Select Windows Destop in the template dialog under Visual C++, and Dynamic-Link Library in the center panel.

3. Enter the “Name:” in the lower panel. Click “OK”.

4. Click on your project name (right under the solution) and control click to bring up the project menu. Select properties. Change the following in the properties page.

C/C++ General
    Additional Include Directories C:\Program Files\pd\src;%(AdditionalIncludeDirectories)
    SDL checks No (/sdl-)
C/C++ Preprocessor 
    Preprocessor Definitions PD;NT;%(PreprocessorDefinitions)
C/C++ Precompiled Header
    Precompiled Header Not Using Precompiled Header
Linker Input
    Additional Dependencies oldnames.lib;kernel32.lib;C:\Program Files\pd\bin\pd.lib;%(AdditionalDependencies)
    Module Definition File .\externalname.def

5. Add or create your external source code file (externalname.c). You might want to start with a known working file (obj1.c or dspobj.c) to start. Remove the Source Files dllmain.cpp and pch.cpp. Remove the Header Files framework.h and pch.h. A definition file will need to be created for the external to designate the setup function, this is pictured below.

6. Add the line “#define PD_LONGINTTYPE long long” above “#include “m_pd.h” if you are compiling for 64 bit.

7. You should now be able to build your external. Go to the build menu and select Build externalname.

8. To debug your external, create a .pd file in the folder that your external resides. Assuming you started Pure Data to create this file, your next step is to connect the debugger.

9. Go to the Debug menu and select Attach to Process. Do not attach to Pd.com, instead select pd.exe. This is the part of Pd that actually loads and runs your external.

10. Now you can enter break points in the .c file. Visual Studio will stop execution at these points so that you can inspect variables and check whether things are working properly.

11. Add your external to the .pd file you created in step 8. If all goes well, Xcode will jump to the foreground when it stops at the break point. Now you can look at variable and step through your code one line at a time.

Leave a Reply

Your email address will not be published.