Monthly Archives: January 2022

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.

PD externals in Xcode (v11)

  1. Create a new project (New>Project… from file menu)
  2. Select macOS in the template dialog, and Library under Framework & Library

3. Enter a “Product Name:”, select None for “Framework:” and Dynamic for “Type:”

4. Click on your project (blue icon in left column) and Build Settings in the center panel. Set the following:

Deployment
    Installation Build Products Location /
    Installation Directory (your project directory)
    Skip Install No
Linking
    Other Linker Flags -flat_namespace -undefined suppress
Packaging
    Executable Extension pd_darwin
    Executable Prefix (delete lib, leave empty)
    Product Name (your external name)
Search Paths
    Header Search Paths /Applications/Pd-0.51-4.app/Contents/Resources/src (change for Pd version)

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.

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

7. 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.

8. Go to the Debug menu and select Attach to Process. Do not attach to Pd, instead, scroll further down to the “System” section and select pd. This is the part of Pd that actually loads and runs your external.

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

10. Add your external to the .pd file you created in step 7. 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.