[PD] Problem compiling hello world external

Martin Peach martinrp at vax2.concordia.ca
Thu Sep 30 17:53:34 CEST 2004

Jamie Bullock wrote:

> Dear list,
> I am thinking of writing a few PD externals, and so decided to try the 
> HOW-TO tutorial at http://iem.kug.ac.at/pd/externals-HOWTO/node1.html.
> I am using gcc 3.3.3. m_pd.h is version 0.37 and is in /usr/include.
> The problem is that if I simply copy and paste the helloworld code 
> into  a text  editor and try to compile with something like:
> gcc helloworld_pd.c -o  helloworld.pd_linux -l/usr/include
> It fails with the wollowing output:
> /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/../../../crt1.o(.text+0x18): 
> In function `_start':
> : undefined reference to `main'

Here gcc is looking to compile a regular executable, when you really 
want it to build a shared library.

> /tmp/ccWU3J7M.o(.text+0xf): In function `helloworld_bang':
> : undefined reference to `post'

This and the following errors all relate to gcc not being able to find 
the pd header files, the first of which is m_pd.h.

> /tmp/ccWU3J7M.o(.text+0x28): In function `helloworld_new':
> : undefined reference to `pd_new'
> /tmp/ccWU3J7M.o(.text+0x53): In function `helloworld_setup':
> : undefined reference to `gensym'
> /tmp/ccWU3J7M.o(.text+0x5c): In function `helloworld_setup':
> : undefined reference to `class_new'
> /tmp/ccWU3J7M.o(.text+0x77): In function `helloworld_setup':
> : undefined reference to `class_addbang'
> collect2: ld returned 1 exit status
> I apologise in advance if this question has already been answered - I 
> couldn't find anything in the mail archives...

Previous posts have alluded to the absence of this vital information 
from the HOW-TO...

> Any help would be appreciated.
Assuming you have the source for pd, check out the makefile in 
pd/extra/pique for an example of how to do it properly on all platforms. 
In particular note the need for -export_dynamic and -shared to indicate 
that you want to build a shared library, as well as -I../../src to give 
the path to m_pd.h. The easiest thing is usually to copy such a makefile 
and modify the file names and paths to suit your setup, then type 'make' 
to build your external.


More information about the Pd-list mailing list