<div dir="ltr">As an update for any potential future Pd-nauts...<div><br></div><div>The issue: Why don't my 3rd party externals load in libpd within my Windows application?</div><div><br></div><div>The cause: It's due to pre-compiled dlls for Windows implictly linking against <span style="font-size:12.800000190734863px">Pd/bin/</span>pd.dll. The external dll get's unloaded when it's pd.dll dependency can not be found.</div><div><br></div><div>The solution:  Modify the libpd MINGW makefile so that the library output is pd.dll instead of libpd.dll</div><div><br></div><div>Many thanks to the help from @Chrisof, who also kindly submitted a PR with some more discussion here: <a href="https://github.com/libpd/libpd/pull/241">https://github.com/libpd/libpd/pull/241</a></div><div><br></div><div>Thanks,</div><div>Joe</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 21 May 2018 at 11:38, Christof Ressi <span dir="ltr"><<a href="mailto:christof.ressi@gmx.at" target="_blank">christof.ressi@gmx.at</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">hmmm, I might try it myself in the next few days.<br>
<br>
BTW,<br>
<span class=""><br>
> also using the windows .lib to statically import the symbols.<br>
<br>
</span>the import library (.lib) is only necessary if you work with MSVC, GCC can directly link to a DLL<br>
 <br>
 <br>
<br>
Gesendet: Montag, 21. Mai 2018 um 12:10 Uhr<br>
<span class="">Von: "Joe White" <<a href="mailto:white.joe4@gmail.com">white.joe4@gmail.com</a>><br>
An: "Christof Ressi" <<a href="mailto:christof.ressi@gmx.at">christof.ressi@gmx.at</a>><br>
Cc: Pd-list <<a href="mailto:pd-list@lists.iem.at">pd-list@lists.iem.at</a>><br>
</span>Betreff: Re: Re: [PD] Using externals with libpd on Windows<br>
<span class=""><br>
I'm linking against libpd dynamically, also using the windows .lib to statically import the symbols.<br>
 <br>
</span>On 18 May 2018 at 19:35, Christof Ressi <<a href="mailto:christof.ressi@gmx.at">christof.ressi@gmx.at</a>[mailto:<a href="mailto:christof.ressi@gmx.at"><wbr>christof.ressi@gmx.at</a>]> wrote:just to be sure: are you using a static or dynamic version of libpd in your program?<br>
<span class=""><br>
Gesendet: Freitag, 18. Mai 2018 um 17:38 Uhr<br>
</span>Von: "Joe White" <<a href="mailto:white.joe4@gmail.com">white.joe4@gmail.com</a>[mailto:<a href="mailto:white.joe4@gmail.com">w<wbr>hite.joe4@gmail.com</a>]><br>
An: "Christof Ressi" <<a href="mailto:christof.ressi@gmx.at">christof.ressi@gmx.at</a>[mailto:<a href="mailto:christof.ressi@gmx.at"><wbr>christof.ressi@gmx.at</a>]><br>
Cc: Pd-list <<a href="mailto:pd-list@lists.iem.at">pd-list@lists.iem.at</a>[mailto:<a href="mailto:pd-list@lists.iem.at">p<wbr>d-list@lists.iem.at</a>]><br>
<span class="">Betreff: Re: [PD] Using externals with libpd on Windows<br>
<br>
Thanks for the info Christof!<br>
 <br>
It seems to me that compiling libpd via the makefile [0] in mingw already exports all the symbols correctly.<br>
<br>
 <br>
Seems like the solution in your link [1] suggests to export the symbols in the exe, and also update the plugins to load the functions via GetProcAddress. I'm trying to avoid touching the 3rd party externals if possible as I can already re-link them against the libpd.dll but don't feel that is very maintainable. <br>
 <br>
Has anyone managed to successfully load pre-compiled externals in a libpd-embedded Windows application?<br>
 <br>
I'm currently trying to see if it's possible to point the externals to the find the pd symbols elsewhere as they get loaded, but my hopes aren't high!<br>
 <br>
Thanks,<br>
Joe<br>
 <br>
</span>[0] <a href="https://github.com/libpd/libpd/blob/master/Makefile#L23[https://github.com/libpd/libpd/blob/master/Makefile#L23]" rel="noreferrer" target="_blank">https://github.com/libpd/<wbr>libpd/blob/master/Makefile#<wbr>L23[https://github.com/libpd/<wbr>libpd/blob/master/Makefile#<wbr>L23]</a><br>
[1] <a href="http://forums.codeguru.com/showthread.php?536343-RESOLVED-accessing-symbols-in-appllication-from-within-dynamic-library-MinGW[http://forums.codeguru.com/showthread.php?536343-RESOLVED-accessing-symbols-in-appllication-from-within-dynamic-library-MinGW][http://forums.codeguru.com/showthread.php?536343-RESOLVED-accessing-symbols-in-appllication-from-within-dynamic-library-MinGW[http://forums.codeguru.com/showthread.php?536343-RESOLVED-accessing-symbols-in-appllication-from-within-dynamic-library-MinGW]]" rel="noreferrer" target="_blank">http://forums.codeguru.<wbr>com/showthread.php?536343-<wbr>RESOLVED-accessing-symbols-in-<wbr>appllication-from-within-<wbr>dynamic-library-MinGW[http://<wbr>forums.codeguru.com/<wbr>showthread.php?536343-<wbr>RESOLVED-accessing-symbols-in-<wbr>appllication-from-within-<wbr>dynamic-library-MinGW][http://<wbr>forums.codeguru.com/<wbr>showthread.php?536343-<wbr>RESOLVED-accessing-symbols-in-<wbr>appllication-from-within-<wbr>dynamic-library-MinGW[http://<wbr>forums.codeguru.com/<wbr>showthread.php?536343-<wbr>RESOLVED-accessing-symbols-in-<wbr>appllication-from-within-<wbr>dynamic-library-MinGW]]</a><br>
 <br>
On 11 May 2018 at 20:04, Christof Ressi <<a href="mailto:christof.ressi@gmx.at">christof.ressi@gmx.at</a>[mailto:<a href="mailto:christof.ressi@gmx.at"><wbr>christof.ressi@gmx.at</a>][mailto:<a href="mailto:christof.ressi@gmx.at"><wbr>christof.ressi@gmx.at</a>[mailto:<a href="mailto:christof.ressi@gmx.at">c<wbr>hristof.ressi@gmx.at</a>]]> wrote:yes, this is a limitation on windows where a DLL can't automatically import symbols from the executable where it was loaded (what you get on Linux with --export-dynamic). for Pd the solution is to make the app itself a thin wrapper around a DLL (pd.dll) which plugins can link to.<br>
<span class=""><br>
I found this link which might be helpful:<br>
<br>
</span><a href="http://forums.codeguru.com/showthread.php?536343-RESOLVED-accessing-symbols-in-appllication-from-within-dynamic-library-MinGW[http://forums.codeguru.com/showthread.php?536343-RESOLVED-accessing-symbols-in-appllication-from-within-dynamic-library-MinGW][http://forums.codeguru.com/showthread.php?536343-RESOLVED-accessing-symbols-in-appllication-from-within-dynamic-library-MinGW[http://forums.codeguru.com/showthread.php?536343-RESOLVED-accessing-symbols-in-appllication-from-within-dynamic-library-MinGW]]" rel="noreferrer" target="_blank">http://forums.codeguru.com/<wbr>showthread.php?536343-<wbr>RESOLVED-accessing-symbols-in-<wbr>appllication-from-within-<wbr>dynamic-library-MinGW[http://<wbr>forums.codeguru.com/<wbr>showthread.php?536343-<wbr>RESOLVED-accessing-symbols-in-<wbr>appllication-from-within-<wbr>dynamic-library-MinGW][http://<wbr>forums.codeguru.com/<wbr>showthread.php?536343-<wbr>RESOLVED-accessing-symbols-in-<wbr>appllication-from-within-<wbr>dynamic-library-MinGW[http://<wbr>forums.codeguru.com/<wbr>showthread.php?536343-<wbr>RESOLVED-accessing-symbols-in-<wbr>appllication-from-within-<wbr>dynamic-library-MinGW]]</a><br>
<span class=""><br>
I guess if you compile libpd as a DLL (with "--export-all-symbols") existing externals should load.<br>
 <br>
<br>
<br>
Gesendet: Freitag, 11. Mai 2018 um 19:21 Uhr<br>
</span>Von: "Joe White" <<a href="mailto:white.joe4@gmail.com">white.joe4@gmail.com</a>[mailto:<a href="mailto:white.joe4@gmail.com">w<wbr>hite.joe4@gmail.com</a>][mailto:<a href="mailto:white.joe4@gmail.com">wh<wbr>ite.joe4@gmail.com</a>[mailto:<a href="mailto:white.joe4@gmail.com">whit<wbr>e.joe4@gmail.com</a>]]><br>
An: Pd-list <<a href="mailto:pd-list@lists.iem.at">pd-list@lists.iem.at</a>[mailto:<a href="mailto:pd-list@lists.iem.at">p<wbr>d-list@lists.iem.at</a>][mailto:<a href="mailto:pd-list@lists.iem.at">pd<wbr>-list@lists.iem.at</a>[mailto:<a href="mailto:pd-list@lists.iem.at">pd-<wbr>list@lists.iem.at</a>]]><br>
<span class="">Betreff: [PD] Using externals with libpd on Windows<br>
<br>
Hi all, <br>
 <br>
I recently spent a bit of time tracking down why a patch wasn't loading a couple of externals in a windows application that embeds libpd.<br>
 <br>
The patch was using vbap [0] and soundfile_info from iemlib [1].<br>
 <br>
The issue I found was that the pre-built binaries that work in the window version of the Pd authoring environment were linking against pd.dll (I'm assuming from Pd/bin/) in order to correctly link against the plugin API methods exposed in m_pd.h.<br>
 <br>
The solution I recently came to, though admittedly a bit of a hack, was to generate a custom VS2017 dll project for both vbap, and soundfile_info, include the relevant source files, and link against the compiled version of libpd to resolve the missing symbols instead of the authoring libraries.<br>
 <br>
The downside of this approach is that the manually compiled externals will no longer run in the Pd authoring environment, and it's not really maintainable from a development perspective. <br>
 <br>
>From my days of making externals for macos, I don't think I ever had to link against Pd, but just include m_pd.h and be done.<br>
 <br>
My question is whether this is usual behaviour when working with externals/libpd on Windows or if I'm missing something somewhere?<br>
 <br>
Any perspective would be much appreciated!<br>
 <br>
Thanks,<br>
Joe<br>
 <br>
</span>[0] <a href="https://puredata.info/downloads/vbap[https://puredata.info/downloads/vbap][1][https://puredata.info/downloads/vbap[https://puredata.info/downloads/vbap][1]]" rel="noreferrer" target="_blank">https://puredata.info/<wbr>downloads/vbap[https://<wbr>puredata.info/downloads/vbap][<wbr>1][https://puredata.info/<wbr>downloads/vbap[https://<wbr>puredata.info/downloads/vbap][<wbr>1]]</a> <a href="https://git.iem.at/pd/iemlib[https://git.iem.at/pd/iemlib]_______________________________________________[https://git.iem.at/pd/iemlib[https://git.iem.at/pd/iemlib]_______________________________________________][https://git.iem.at/pd/iemlib[https://git.iem.at/pd/iemlib]_______________________________________________[https://git.iem.at/pd/iemlib[https://git.iem.at/pd/iemlib]_______________________________________________]]" rel="noreferrer" target="_blank">https://git.iem.at/pd/<wbr>iemlib[https://git.iem.at/pd/<wbr>iemlib]_______________________<wbr>________________________[<wbr>https://git.iem.at/pd/iemlib[<wbr>https://git.iem.at/pd/iemlib]_<wbr>______________________________<wbr>________________][https://git.<wbr>iem.at/pd/iemlib[https://git.<wbr>iem.at/pd/iemlib]_____________<wbr>______________________________<wbr>____[https://git.iem.at/pd/<wbr>iemlib[https://git.iem.at/pd/<wbr>iemlib]_______________________<wbr>________________________]]</a> <a href="mailto:Pd-list@lists.iem.at">Pd-list@lists.iem.at</a>[mailto:<a href="mailto:Pd-list@lists.iem.at">Pd<wbr>-list@lists.iem.at</a>][mailto:<a href="mailto:Pd-list@lists.iem.at">Pd-<wbr>list@lists.iem.at</a>[mailto:<a href="mailto:Pd-list@lists.iem.at">Pd-<wbr>list@lists.iem.at</a>]] mailing list UNSUBSCRIBE and account-management -> <a href="https://lists.puredata.info/listinfo/pd-list[https://lists.puredata.info/listinfo/pd-list][https://lists.puredata.info/listinfo/pd-list[https://lists.puredata.info/listinfo/pd-list]][https://lists.puredata.info/listinfo/pd-list[https://lists.puredata.info/listinfo/pd-list][https://lists.puredata.info/listinfo/pd-list[https://lists.puredata.info/listinfo/pd-list]]]" rel="noreferrer" target="_blank">https://lists.puredata.info/<wbr>listinfo/pd-list[https://<wbr>lists.puredata.info/listinfo/<wbr>pd-list][https://lists.<wbr>puredata.info/listinfo/pd-<wbr>list[https://lists.puredata.<wbr>info/listinfo/pd-list]][https:<wbr>//lists.puredata.info/<wbr>listinfo/pd-list[https://<wbr>lists.puredata.info/listinfo/<wbr>pd-list][https://lists.<wbr>puredata.info/listinfo/pd-<wbr>list[https://lists.puredata.<wbr>info/listinfo/pd-list]]]</a><br>
</blockquote></div><br></div>