On Thu, Jul 14, 2011 at 7:02 PM, Hans-Christoph Steiner <hans@at.or.at> wrote:

On Thu, 14 Jul 2011 12:44 -0400, "Mathieu Bouchard" <matju@artengine.ca>
wrote:
> On Thu, 14 Jul 2011, luca paganotti wrote:
>
> > but ... I get 'undefined reference' (s) for all the pd symbols that are
> > used by helloworld.c i.e. pd_new, gensym, class_new, class_addbang, post
>
> You need to use the -shared option to produce a .so or .DLL file.
>
> In addition, you need to link with PD.DLL (a Windows-only requirement...
> no such equivalent on other platforms).

Hey Luca,

This is great, that you got this far!  Can you write up a wiki page in
the dev section. Don't worry too much about formatting, mostly just get
the info in there.
http://puredata.info/docs/developer

I think it's a very trivial thing for a wiki page, I mean is not such a great thing ....
 

As for Makefiles, if you use the the Library Template, then the Makefile
will work on MinGW, Cygwin, Mac OS X, GNU/Linux, Android, iOS, etc.
http://puredata.info/docs/developer/LibraryTemplate

.hc

ok, got the template from svn,

use it as it is trying to build a 'mycobject' as defined by the code ...

getting these results in eclipse console:

**** Build of configuration Default for project mycobject ****

make all
Building target: mycobject
Invoking: MinGW C++ Linker
g++ -L"C:\Programmi\pd\bin" -o"mycobject"  ./mycobject.o   -l"C:/Programmi/pd/bin/pd.lib"
c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -lC:/Programmi/pd/bin/pd.lib
collect2: ld returned 1 exit status
make: *** [mycobject] Error 1

what I really do not understand is that I have my pd.lib file exactly in the folder were ld on bhalf eclipse searches for it, i.e. C:\Programmi\pd\bin\pd.lib

Anyway I then tryed the hard way from the mingw console issueing a 'make all' getting finally a usefull error message:

Pag@XP-PAG /c/dev/c++/pd-externals/mycobject
$ make clean
sed: can't read mycobject-meta.pd: No such file or directory
sed: can't read mycobject-meta.pd: No such file or directory
sed: can't read mycobject-meta.pd: No such file or directory
sed: can't read mycobject-meta.pd: No such file or directory
sed: can't read mycobject-meta.pd: No such file or directory
rm -f -- mycobject.o
rm -f -- mycobject.dll
rm -f -- mycobject.o
rm -f -- mycobject.dll

Pag@XP-PAG /c/dev/c++/pd-externals/mycobject
$ make all
sed: can't read mycobject-meta.pd: No such file or directory
sed: can't read mycobject-meta.pd: No such file or directory
sed: can't read mycobject-meta.pd: No such file or directory
sed: can't read mycobject-meta.pd: No such file or directory
sed: can't read mycobject-meta.pd: No such file or directory
sed: can't read mycobject-meta.pd: No such file or directory
cc -I"/c/Programmi/pd/include/pd" -Wall -W -g -DPD -DVERSION='""' -mms-bitfields
 -O3 -funroll-loops -fomit-frame-pointer -o "mycobject.o" -c "mycobject.c"
/bin/sh: cc: command not found
make: *** [mycobject.o] Error 127

perhaps does it means that the compiler command is not defined in the makefile?

I added this line

CC = gcc

between the OS = windows and PD_PATH = $(shell cd "$(PROGRAMFILES)"/pd && pwd) lines

inside the ifeq (MINGW,$(findstring MINGW,$(UNAME))) ... endif  block  

and then got:

Pag@XP-PAG /c/dev/c++/pd-externals/mycobject
$ make all
sed: can't read mycobject-meta.pd: No such file or directory
sed: can't read mycobject-meta.pd: No such file or directory
sed: can't read mycobject-meta.pd: No such file or directory
sed: can't read mycobject-meta.pd: No such file or directory
sed: can't read mycobject-meta.pd: No such file or directory
sed: can't read mycobject-meta.pd: No such file or directory
gcc -I"/c/Programmi/pd/include/pd" -Wall -W -g -DPD -DVERSION='""' -mms-bitfield
s -O3 -funroll-loops -fomit-frame-pointer -o "mycobject.o" -c "mycobject.c"
gcc  -s -shared -Wl,--enable-auto-import -o "mycobject.dll" "mycobject.o"   -L"/
c/Programmi/pd/src/" -L"/c/Programmi/pd/bin/" -lpd -lwsock32 -lkernel32 -luser32
 -lgdi32
chmod a-x "mycobject.dll"

Pag@XP-PAG /c/dev/c++/pd-externals/mycobject
$

I got the mycobject dll that runs fine under pd-extended on a windows box.

Still wondering why eclise doen't find my pd.lib

At least this is working now from the command line.