Hi Ed, <div><br></div><div>Sorry for the delay, these emails got filtered out of my inbox for some reason :(</div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

You make the object in C, compile it and then build your patch in pd vanilla + the object.<br>Then in the xcode object you just call the setup function for the object, the source code for which gets included in the xcode project.<br>

That&#39;s all I know. I&#39;m not responsible for the Xcode/C++ of this app, only the Pd patch and Pd objects, so there may be more to it. It&#39;s quite simple though, my developer colleague tells me.<br>Don&#39;t forget, C is a subset of C++!</blockquote>

<div><br></div><div>Yep, this is what I&#39;m doing. The issue is that to call C++ code in the C external I need to compile it with a C++ compile, therefore I change the source code extension to .mm (objective-c++). Now when I do this Xcode goes all weird about class_addmethod(), which is maybe a namespace issue - I&#39;m not sure. But it means I can&#39;t add any methods in the external. </div>

<div><br></div><div>The solution I used was to write a C wrapper for the C++ library, it&#39;s a bit annoying as any function I want to use has to be declared in the wrapper, but it works so I can&#39;t complain. Maybe your dev guy might have a solution? :)</div>

<div><br></div><div>Glad to see others using Pd on iOS/Android!</div><div><br></div><div>Cheers,</div><div>Joe</div><div>  </div><br><div class="gmail_quote">On 27 April 2012 21:54, Ed Kelly <span dir="ltr">&lt;<a href="mailto:morph_2016@yahoo.co.uk" target="_blank">morph_2016@yahoo.co.uk</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-size:12pt;font-family:times new roman,new york,times,serif"><div><span>It&#39;s really easy actually.</span></div>

<div><br><span></span></div><div><span>You make the object in C, compile it and then build your patch in pd vanilla + the object.</span></div><div><span>Then in the xcode object you just call the setup function for the object, the source code for which gets included in the xcode project.</span></div>

<div><span>That&#39;s all I know. I&#39;m not responsible for the Xcode/C++ of this app, only the Pd patch and Pd objects, so there may be more to it. It&#39;s quite simple though, my developer colleague tells me.</span></div>

<div><span>Don&#39;t forget, C is a subset of C++!<br></span></div><div class="im"><div><br><span></span></div><div><span>Ed</span></div><div> </div><div>Gemnotes-0.1alpha: Live music notation for Pure Data<br><a href="http://sharktracks.co.uk/" target="_blank">http://sharktracks.co.uk/</a><br>

</div>  </div><div style="font-family:times new roman,new york,times,serif;font-size:12pt"> <div style="font-family:times new roman,new york,times,serif;font-size:12pt"> <div dir="ltr"> <font face="Arial"><div class="im">

 <hr size="1">  <b><span style="font-weight:bold">From:</span></b> Joe White &lt;<a href="mailto:white.joe4@gmail.com" target="_blank">white.joe4@gmail.com</a>&gt;<br> </div><b><span style="font-weight:bold">To:</span></b> Charles Henry &lt;<a href="mailto:czhenry@gmail.com" target="_blank">czhenry@gmail.com</a>&gt; <br>

<b><span style="font-weight:bold">Cc:</span></b> pd-list &lt;<a href="mailto:pd-list@iem.at" target="_blank">pd-list@iem.at</a>&gt; <br> <b><span style="font-weight:bold">Sent:</span></b> Friday, 27 April 2012, 9:56<br> <b><span style="font-weight:bold">Subject:</span></b> Re: [PD] [Pd] Compile external with C++ compiler?<br>

 </font> </div><div><div class="h5"> <br><div><div>Hi Charles,</div><div><br></div><div>Thanks for replying!</div><div><br></div><div>I don&#39;t believe
 it&#39;s a problem calling C functions, you just have to declare them with &#39;extern &quot;C&quot;&#39; to avoid name mangling (I think??). </div>

<div><br></div><div>The issue is, when I want to use C++ I have to switch the implementation file to &quot;.mm&quot;, which is a Objective-C++ file. As soon as I do this Xcode starts complaining about &#39;class_addmethod()&#39; in my setup function. The weird thing is that it only applies to &#39;class_addmethod()&#39;. For example, &#39;class_addbang()&#39;, &#39;class_new()&#39; all work fine. </div>



<div><br></div><div>It seems like it&#39;s an issue only with this function, and it looks like <a rel="nofollow" href="https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html" target="_blank">class_addMethod is already a function used by Objective-C </a> I think maybe there&#39;s some namespace issues, but I have no idea how to resolve this. </div>



<div><br></div><div><blockquote style="border-left:1px solid rgb(204,204,204);margin:0px 0px 0px 0.8ex;padding-left:1ex">

wrote wrapper functions to export a C-callable public interface to C++ functions. </blockquote><div><br></div><div>Yep, this is what I&#39;m doing now. A bit annoying because I was so close :) </div><div><br></div><div>Thanks for your help!</div>



<div><br></div><div>Cheers,</div><div>Joe </div><br><div>On 27 April 2012 04:10, Charles Henry <span dir="ltr">&lt;<a rel="nofollow" href="mailto:czhenry@gmail.com" target="_blank">czhenry@gmail.com</a>&gt;</span> wrote:<br>



<blockquote style="border-left:1px solid rgb(204,204,204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">Hi guys<br>
<br>
The part that I don&#39;t get is how to call C functions from C++? I don&#39;t<br>
think I&#39;ve even tried that before.  Have you?<br>
Joe: I&#39;ve built externals that just call C++ functions that I declared<br>
with extern &quot;C&quot; or wrote wrapper functions to export a C-callable<br>
public interface to C++ functions.  Best suggestion I&#39;ve got is to<br>
identify which functions you&#39;ve got are going to be public and which<br>
ones are private and plan out how you&#39;re going to declare them.<br>
<br>
Chuck<br>
<div><div><br>
On 4/26/12, Ed Kelly &lt;<a rel="nofollow" href="mailto:morph_2016@yahoo.co.uk" target="_blank">morph_2016@yahoo.co.uk</a>&gt; wrote:<br>
&gt; Hi Joe,<br>
&gt;<br>
&gt; Have you thought of using ofxPd?<br>
&gt;<br>
&gt; I&#39;m involved in the creation of an app for the iPhone right now, and we&#39;re<br>
&gt; using ofxPd from Dan Wilcox:<br>
&gt; <a rel="nofollow" href="https://github.com/danomatika/ofxPd" target="_blank">https://github.com/danomatika/ofxPd</a><br>
&gt; Since Openframeworks is a bunch of C++ wrappers for various libraries, ofxPd<br>
&gt; adds Pd to the libraries that you can work with in C++.<br>
&gt; Then you can call the setup function within the xcode build, and your object<br>
&gt; will work in libpd (i.e. ofxPd) in the app environment.<br>
&gt; Bear in mind that Apple do not like GnuGPL licensed stuff, so I&#39;ve created<br>
&gt; BSD licensed versions of some of my own Pd externals for this project.<br>
&gt;<br>
&gt;<br>
&gt; And the app works. We&#39;re in the final stages now, so I&#39;ll post to the list<br>
&gt; when it&#39;s complete!<br>
&gt; Best,<br>
&gt; Ed<br>
&gt;<br>
&gt;<br>
&gt; Gemnotes-0.1alpha: Live music notation for Pure Data<br>
&gt; <a rel="nofollow" href="http://sharktracks.co.uk/" target="_blank">http://sharktracks.co.uk/</a><br>
&gt;<br>
&gt;<br>
&gt; ________________________________<br>
&gt;  From: Joe White &lt;<a rel="nofollow" href="mailto:white.joe4@gmail.com" target="_blank">white.joe4@gmail.com</a>&gt;<br>
&gt; To: pd-list &lt;<a rel="nofollow" href="mailto:pd-list@iem.at" target="_blank">pd-list@iem.at</a>&gt;<br>
&gt; Sent: Thursday, 26 April 2012, 16:51<br>
&gt; Subject: [PD] [Pd] Compile external with C++ compiler?<br>
&gt;<br>
&gt;<br>
&gt; Hi all,<br>
&gt;<br>
&gt; Thought I might as well ask this here because you guys know everything :)<br>
&gt;<br>
&gt; I&#39;m writing an external to be built into an iOS app that&#39;s running Pd. The<br>
&gt; catch is I need to interface with a C++ library within the external.<br>
&gt;<br>
&gt; The external builds and runs fine if I&#39;m using the C compiler (in Xcode) but<br>
&gt; I can&#39;t access the C++ library functions. If I switch it to compile in C++<br>
&gt; (by changing the objective-c file from .m to .mm) then I can use the C++<br>
&gt; library functions but it complains that it can&#39;t find &#39;class_addmethod&#39;<br>
&gt;<br>
&gt;                           &#39;No matching function for call to<br>
&gt; &#39;class_addmethod&#39;<br>
&gt;<br>
&gt; I&#39;ve tried declaring the setup function as C code like Katja explains on her<br>
&gt; site:<br>
&gt;                           extern &quot;C&quot; void external_tilde_setup(void) { }<br>
&gt; But that still didn&#39;t seem to work. I was also going through the list and<br>
&gt; found this thread but I&#39;m not sure if it&#39;s the right approach. Plus I&#39;m more<br>
&gt; of an audio guy than programmer :)<br>
&gt;<br>
&gt; Any ideas would be much appreciated.<br>
&gt;<br>
&gt; Thanks,<br>
&gt; Joe<br>
&gt; --<br>
&gt; Follow me on Twitter @diplojocus<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; <a rel="nofollow" href="mailto:Pd-list@iem.at" target="_blank">Pd-list@iem.at</a> mailing list<br>
&gt; UNSUBSCRIBE and account-management -&gt;<br>
&gt; <a rel="nofollow" href="http://lists.puredata.info/listinfo/pd-list" target="_blank">http://lists.puredata.info/listinfo/pd-list</a><br>
<br>
_______________________________________________<br>
<a rel="nofollow" href="mailto:Pd-list@iem.at" target="_blank">Pd-list@iem.at</a> mailing list<br>
UNSUBSCRIBE and account-management -&gt; <a rel="nofollow" href="http://lists.puredata.info/listinfo/pd-list" target="_blank">http://lists.puredata.info/listinfo/pd-list</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Follow me on Twitter @diplojocus<br>
</div>
</div><br>_______________________________________________<br><a href="mailto:Pd-list@iem.at" target="_blank">Pd-list@iem.at</a> mailing list<br>UNSUBSCRIBE and account-management -&gt; <a href="http://lists.puredata.info/listinfo/pd-list" target="_blank">http://lists.puredata.info/listinfo/pd-list</a><br>

<br><br> </div></div></div> </div>  </div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Follow me on Twitter @diplojocus<br>
</div>