{"id":624,"date":"2022-01-29T00:43:18","date_gmt":"2022-01-29T00:43:18","guid":{"rendered":"https:\/\/synthnotes.ucsd.edu\/wp7\/?p=624"},"modified":"2022-01-29T23:16:32","modified_gmt":"2022-01-29T23:16:32","slug":"pd-externals-in-visual-studio-2017","status":"publish","type":"post","link":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/2022\/01\/29\/pd-externals-in-visual-studio-2017\/","title":{"rendered":"PD externals in Visual Studio 2017"},"content":{"rendered":"\n<ol class=\"wp-block-list\"><li>Create a new project (New&gt;Project&#8230; from file menu)<\/li><li>Select <strong>Windows Destop<\/strong> in the template dialog under <strong>Visual C++<\/strong>, and <strong>Dynamic-Link Library<\/strong> in the center panel.<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"946\" height=\"661\" src=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2022\/01\/Screen-Shot-2022-01-28-at-4.08.19-PM-2.png\" alt=\"\" class=\"wp-image-626\" srcset=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2022\/01\/Screen-Shot-2022-01-28-at-4.08.19-PM-2.png 946w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2022\/01\/Screen-Shot-2022-01-28-at-4.08.19-PM-2-300x210.png 300w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2022\/01\/Screen-Shot-2022-01-28-at-4.08.19-PM-2-768x537.png 768w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2022\/01\/Screen-Shot-2022-01-28-at-4.08.19-PM-2-624x436.png 624w\" sizes=\"auto, (max-width: 946px) 100vw, 946px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">3. Enter the &#8220;Name:&#8221; in the lower panel. Click &#8220;OK&#8221;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">4. Click on your project name (right under the solution) and <strong>control click <\/strong>to bring up the project menu. Select <strong>properties<\/strong>. Change the following in the properties page.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">C\/C++ General\n    Additional Include Directories C:\\Program Files\\pd\\src;%(AdditionalIncludeDirectories)\n    SDL checks No (\/sdl-)\nC\/C++ Preprocessor \n    Preprocessor Definitions PD;NT;%(PreprocessorDefinitions)\nC\/C++ Precompiled Header\n    Precompiled Header Not Using Precompiled Header\nLinker Input\n    Additional Dependencies oldnames.lib;kernel32.lib;C:\\Program Files\\pd\\bin\\pd.lib;%(AdditionalDependencies)\n    Module Definition File .\\externalname.def<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">5. Add or create your external source code file (<em>externalname<\/em>.c). You might want to start with a known working file (obj1.c or dspobj.c) to start. Remove the <strong>Source Files<\/strong> dllmain.cpp and pch.cpp. Remove the <strong>Header Files<\/strong> 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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"792\" height=\"424\" src=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2022\/01\/Screen-Shot-2022-01-29-at-3.10.53-PM-2.png\" alt=\"\" class=\"wp-image-628\" srcset=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2022\/01\/Screen-Shot-2022-01-29-at-3.10.53-PM-2.png 792w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2022\/01\/Screen-Shot-2022-01-29-at-3.10.53-PM-2-300x161.png 300w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2022\/01\/Screen-Shot-2022-01-29-at-3.10.53-PM-2-768x411.png 768w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2022\/01\/Screen-Shot-2022-01-29-at-3.10.53-PM-2-624x334.png 624w\" sizes=\"auto, (max-width: 792px) 100vw, 792px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">6. Add the line &#8220;#define PD_LONGINTTYPE long long&#8221; above  &#8220;#include &#8220;m_pd.h&#8221; if you are compiling for 64 bit.<br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">7. You should now be able to build your external. Go to the build menu and select <strong>Build externalname.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">9. Go to the Debug menu and select <strong>Attach to Process<\/strong>. Do not attach to <strong>Pd.com<\/strong>, instead select <strong>pd.exe<\/strong>. This is the part of Pd that actually loads and runs your external.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Create a new project (New&gt;Project&#8230; from file menu) Select Windows Destop in the template dialog under Visual C++, and Dynamic-Link Library in the center panel. 3. Enter the &#8220;Name:&#8221; in the lower panel. Click &#8220;OK&#8221;. 4. Click on your project name (right under the solution) and control click to bring up the project menu. Select [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-624","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/posts\/624","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/comments?post=624"}],"version-history":[{"count":4,"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/posts\/624\/revisions"}],"predecessor-version":[{"id":630,"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/posts\/624\/revisions\/630"}],"wp:attachment":[{"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/media?parent=624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/categories?post=624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/tags?post=624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}