Hm. That's right, I guess there was a typo in my post above (fixed now): it is projects/pd-externals
Compiling puredata externals
giuliomoro could have almost guessed that
but I still get this error:
mirror~
error: ... couldn't create
error: signal outlet connect to nonsignal inlet (ignored)
when I put the external into the project folder directly, it works.
Path is ~/Bela/projects/pd-externals , object is called mirror~.pd_linux
- Edited
ok, this sounds strange. Can you check that the render file you are using (whether core/default_libpd_render.cpp
, or a custom one if you have it in your project) has the following lines:
//Add the current folder to the search path for externals
libpd_add_to_search_path(".");
libpd_add_to_search_path("../pd-externals");
If this is ok, then it may be that your YOUROBJECT_new
method is returning NULL
, for whatever reason. Can you add a printf in YOUROBJECT_setup
and YOUROBJECT_new
to make sure they are being called?
ah, using a custom one - which doesn't have that added.
sorry, didn't know the connection was coming from there!
adding those lines worked. thanks!
Hello! I'm struggling with with adding pd externals to my projects.
Is is possible to use xxx.pd_darwin externals or does it have to be xxx.pd_linux externals?
I tried to use the template mentioned earlier both running make file on OSX and in ubuntu64 bit and 32 bit.
I only get error ... couldn't create with OSX and ubuntu 32 bit.
With ubuntu 64bit I get a message ./hrtf2~.pd_linux: ./hrtf2~.pd_linux: wrong ELF class: ELFCLASS64
hrtf2~.pd is my external.
Can any of you clear up what you did right?
Sorry I never got around writing appropriate instructions for this. You have to compile the externals on the BeagleBone itself. At that point, your compiled file will be called hrtf2~.pd_linux
. Mind you, this will have a different architecture from the one with the same name which you obtained on your Ubuntu computer(arm the former, x86 the latter).
Thanks a bunch! It's running!
Explanation: I made it work by copying .c .h and makefile to ../projects/pd-externals/ and running makefile from IDE command line.
https://svn.code.sf.net/p/pure-data/svn/trunk/externals/template seems to be gone :/ has anyone made a backup?
- Edited
I guess this should help
https://github.com/pure-data/helloworld
when building on Bela you will want to use at least
make PDINCLUDEDIR=/usr/local/include/libpd/
or
make PD_INCLUDE=/usr/local/include/libpd/
(or something similar, it really depends on your Makefile
).
so that it can find m_pd.h
in /usr/local/include/libpd/
.
Hello,
I think I have similar problem.
I've uploaded and successfully compiled zexy on bella.
Then I moved the compiled external to ~/Bela/projects/pd-externals/ , but my patch located on ~/Bela/projects/Bela-pd does not recognize zexy.
I've tried also to put it into my patch folder, recompile all by doing ./bela-update which resets all and checked for libpd_add_to_search_path("../pd-externals"); in core/default_libpd_render.cpp.
Still the problem exists.
My board is up to date using master-dev branch.
Please help.
how are you importing your zexy
library?
also, do you want to send me your .pd_linux
binary so I can test in on my side?
giuliomoro Maybe that's the missing point as I expected external is being imported automagically as the path is given in core/default_libpd_render.cpp If it comes to usage of it, I am just trying to use datetime objects of zexy. Will send you all the files this afternoon.
- Edited
libpd
will look in pd-externals
for files with the same name as the object you are creating when you try to load an external. As I understand it, zexy
comes as a single-file library, so that, e.g.: there is no date.pd_linux
file in pd-externals
. For this reason, when you try to create the [date]
object, it fails.
There is one way of importing libraries that will work with both Pd and libpd
: create in your patch an object with the name of the library, e.g.: [zexy]
(note: this must be created in your patch before any other object, as the order of creation matters). Then you will be able to create, e.g.: [date]
.
Pd on your computer allows one additional way of doing it: you can go to preferences->startup and preload some libraries (e.g.: zexy
).
On libpd
(on Bela and elsewhere) you can import libraries by manually calling their ..._setup()
function. This involves something like this in the render
file:
NOTE: broken code do not use (see comment below)
// forward declare external setup functions
void zexy_setup();
bool setup(BelaContext* context, void* args) {
.....
// init libpd
libpd_init();
// load libs
zexy_setup();
....
}
Again, you could simply create a [zexy]
object and forget about changing the C++ source code. Yet, if you want to do that , you have a couple of options to apply these changes:
- you could edit the
core/default_libpd_render.cpp
file (not through the Bela IDE). This change is global for all your libpd projects, but when you update the board, these changes will be lost. - you could copy that file to your project's folder and apply the edits on such copy, so the file becomes part of your project and is resilient to changes in the core code. You will then have to do this for each individual project.
More documentation on libpd
and external libraries is here. Note that you don't need the part about "Adding external source files" if you already compiled the library as an external.
giuliomoro Okay,
First of all thanks for your help! After your post I am starting to catch it up. I did a test: created a new patch with zexy and date objects. It came up with zexy message in terminal so it is loaded Now I need to reorder stuff in my patch so zexy will be first one.
I was not aware of how it works. I'll also try your second idea with editing cpp file.
Will post my findings.
Thanks! It's time to get a good filter in my patch...
An easy way to make [zexy]
the first object in the patch is to cut everything else, create [zexy]
and then paste. This way the other objects will come after [zexy]
.
giuliomoro This is exactly what I did. Thanks.
I haven't yet had much luck with calling zexy setup in cpp, but I'll try to work it out.
Anyway the trick with adding zexy as the first element is something I prefer as this way I am able to call it only inside patches that really need that.
Thanks a lot again.
giuliomoro On libpd (on Bela and elsewhere) you can import libraries by manually calling their ..._setup() function. This involves something like this in the render file:
In hindsight, this would not work: the linker will detect that you are declaring and trying to use a symbol that is undefined at link time. So that may work if you are linking those files(e.g.: the zexy .o
files) in your project, but not if you are dynamically loading them as you do with externals.
Im looking to create some pure data externals for bela...
(Ive created max externals before so hopefully not too painful )
anyway, Im seeing that there seem to be multiple template projects for building, these seems to be:
- Makefile supplied with the pure data install (doc/6.externals/Makefile)
- svn Makefile template ( https://svn.code.sf.net/p/pure-data/svn/trunk/externals/template )
- pd-lib-builder (https://github.com/pure-data/pd-lib-builder) , as used by https://github.com/pure-data/helloworld
pd-lib-builder seems to be the latest, and used by a few projects? is this the one to go for?
what Id like is to base my projects on the most supported, and in particular cross-platform e.g. bela (arm), windows, mac, linux (32/64 bit x86)
thoughts?
- Edited
also this one http://puredata.info/docs/developer/Libdir, if it is not included in the above list?
No particular preference myself, the few externals I built (mrpeach, zexy, abl_link~) just seemed to work out of the box with their makefiles on Bela, as long as I could figure out what the right parameter for make
was (e.g.: PDINCLUDEDIR=/usr/local/include/libpd/
vs PD_INCLUDE=/usr/local/include/libpd/
). Oh I also compiled all the externals that come with Pd-l2ork
, so perhaps have a look at how those are handled.