Sorry to have cluttered the list with all this nonsense, but I solved my
problem all by my lonesome. It is all kludge, but it works. The elegant
solution (I think) is to write a nice .configure script that will
generate exactly the right makefile regardless of os and configuration,
but I don't know how to do that.
So, in the meantime one way to link libraries when building Pd externs
(this is for Mac, but it should be pretty much the same on any Unix
outfit) is like this:
modify the file
'/'whatever'/Pd.etc/Contents/Resources/extra/makefile'
so that the first line reads:
'current: pd_darwin'
then in the section that sets the rules and recipes for building on make
it looks so:
'pd_darwin: $(NAME).pd_darwin
.SUFFIXES: .pd_darwin
DARWINCFLAGS = -DPD -O2 -Wall -W -Wshadow -Wstrict-prototypes \
-Wno-unused -Wno-parentheses -Wno-switch
.c.pd_darwin:
$(CC) -arch i386 $(DARWINCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
$(CC) -arch i386 $(LIBS) -bundle -undefined suppress -flat_namespace \
-o $*.pd_darwin $*.o
rm -f $*.o'
I took out all the '.d_ppc' and '-arch ppc' stuff that's in the makefile
that comes with Pd (vanilla) because I have an intel core so ppc junk is
irrelevant. I changed .d_fat to .pd_darwin, because somebody who
actually knows stuff (unlike me) told me that .pd_darwin is the current
convention. The variable 'LINUXINCLUDE' is simply '-I../../src' and is
here recycled from a previous definition in the makefile. It has nothing
to do with linux whatsoever. It just tells the compiler to look at the
Pd source code when you hit make on your external. The other big change
I made is inserting the 'LIBS' variable in the second build phase
instruction which I shall explain below. It is a simple matter to
implement analogous modifications in the other unix-ish portions of the
makefile, but I haven't tested it yet. I don't know anything about
Windows...
Now that the pd makefile is ready to go, go into your extern project
directory and make a makefile there that looks like so:
'NAME=awesomeExtern
CSYM=awesomeExtern
include /'whatever'/Pd.etc/Contents/Resources/extra/makefile
DARWINCFLAGS += -I/path/to/awesome-library/headers etc.
LIBS = -L/path/to/awesome-library -lawesomelibrary etc.'
I put 'etc.' in there because there may be more than one header file or
library that you want to use. You can discover what you need by putting
'pkg-config --cflags awesomelibraryA awesomelibraryB etc.'
into the command line. These return values are what you want to /add/
(note the '+=') to the 'DARWINCFLAGS' variable. Likewise the return of
'pkg-config --libs awesomelibraryA awesomelibraryB etc.'
is what you want to be associated with the 'LIBS' variable. On Mac osx 5
(don't know about 6), the path is usually /opt/local/include and
/opt/local/lib. On Unix/Linux I believe it is typically
/usr/local/include and /usr/local/lib where libraries get installed.
Sorry if this is old-hat to all the C honchos out there and irrelevant
to everyone else (as I suspect is the case). I'm sure it is about a
million times easier if you use Xcode to develop your externs, but then
you would have to use Xcode. If this is helpful/relevant to people I'd
be happy to clean up this little tutorial and post it to the Pd wiki.
Best,
David
On 1/20/11 4:55 PM, david medine wrote:
OK, nuts to that. First, I must correct myself, the makefile I am
referring to is in the Pd.etc.app/Contents/Resources/extra folder. (By
the way, I am at home working on my Mac right now, I haven't tried
this on my beastly linux box at all yet and so I am not sure what all
the details of this issue are there off the top of my head.)
Also, I went ahead and dropped the -c flag from the makefile (this
flag stops linking altogether when make is run) and apparently when
you do this, the extern won't build at all! I think this has something
to do with the fact that in this mode, gcc needs to link with all the
Pd objects also, (because terminal tells me so...) but this
explanation doesn't really make sense to me.
Does anyone know how to tweak the makefile (or any clean method, for
that matter) so that one can link libraries to externals?
Thanks again,
David
On 1/20/11 4:02 PM, david medine wrote:
Dear folks,
Does anybody know a good way to link libraries in a Pd extern build?
I am using plain ol' command line and makefiles. It would be nice to
be able to do this without modifying the Makefile in the
Pd.etc./Contents/Resources/ directory, but due to my general
ignorance of programming lore, I don't really know how to do this.
Any suggestions?
Thanks,
David Medine
_______________________________________________
Pd-list@iem.at mailing list
UNSUBSCRIBE and account-management ->
http://lists.puredata.info/listinfo/pd-list