[PD] error compiling any2string / pd.lib

Martin Peach martin.peach at sympatico.ca
Wed Dec 13 07:06:30 CET 2006


Miguel Cardoso wrote:
> do you know where I can find the pd lib?
>
> thanks for all Martin
>
>
> On Dec 12, 2006, at 8:51 PM, <martin.peach at sympatico.ca> wrote:
>
>> The errors are probably because you are not linking against pd.lib, 
>> which is where the undefined symbols are hiding.
>> Martin
>>
>>>
>>> De: Miguel Cardoso <mcardoso at soopa.org>
>>> Date: 2006/12/12 mar. PM 03:36:28 GMT-05:00
>>> À: pd-liste <pd-list at iem.at>
>>> Objet: [PD] error compiling any2string
>>>
>>> I get this error compiling any2string.c
>>>
>>> does anyone have these moocow externals compiled for mac intel?
>>>
>>> thks list
>>>
>>> cc     any2string.c   -o any2string
>>> /usr/bin/ld: Undefined symbols:
>>> _main

But looking for main implies that you are compiling a program. A pd 
external is a dynamic library.
It seems to me you are on some kind of mac, which I don't know about, 
but I'll try anyway.
Stealing a line or two from a typical pd  makefile:

CFLAGS = -DPD $(OPT_CFLAGS) -I$(pd_src)/src -W $(DEBUG_CFLAGS)
LDFLAGS = 
LIBS = -lm
ifeq ($(OS_NAME),darwin)
  CFLAGS += -I/sw/include -DMACOSX -DUNIX -Dunix
  LDFLAGS += -bundle -bundle_loader $(pd_src)/bin/pd -L/sw/lib
  LIBS += -lc
  DYLIB_LDFLAGS = -dynamiclib -read_only_relocs warning -L/sw/lib
  DYLIB_EXTENSION = dylib
  STRIP = strip -x
and
### C files
%.o: %.c
    $(CC) $(CFLAGS) -o "$*.o" -c "$*.c"

%.$(EXTENSION): %.o
    $(CC) $(LDFLAGS) -o "$*.$(EXTENSION)" "$*.o"  $(LIBS) \
        `test -f $*.libs && cat $*.libs`    \
        `test -f $(dir $*)../$(BUILDSRC_OS_NAME)/$(notdir $*).libs && \
            cat $(dir $*)../$(BUILDSRC_OS_NAME)/$(notdir $*).libs`
    chmod a-x "$*.$(EXTENSION)"
    $(STRIP) $*.$(EXTENSION)
    rm -f -- $*.o


This implies that instead of:
cc     any2string.c   -o any2string
you should write:
cc     any2string.c  -DPD -I/sw/include -I$(pd_src)/src -DMACOSX -DUNIX 
-Dunix -o any2string.o
to compile it, and if that works,
cc -bundle -bundle_loader $(pd_src)/bin/pd -L/sw/lib -o 
anystring.pd_darwin any2string.o -lm -lc
which will link it...except that $(pd_src) should be the path to your pd 
source.
Then:
chmod a-x any2string.pd_darwin
since it's not an executable file, and:
strip -x any2string.pd_darwin
to remove unused code from the binary.
But I don't really know, not having tried it ;(.

Martin

 





More information about the Pd-list mailing list