5 days later

thanks, I compiled several ones, all with complete success!

Nice!
We are actually thinking through how to best integrate building external into the Bela IDE.
So far the plan is to create an example project called 08-PureData/your-external, you open it as an example and save as.
The project will basically contain Pd's externals/template files, with minor modifications. The Makefile included with the project will make sure that once the project is built, the produced binary is moved to a folder (e.g.: ~/Bela/projects/pd-externals/), which in turn should be added by default to libpd-based projects.

Not sure how to better handle the libdir part of pd's external/template: this allows to easily create libraries of externals (as opposed to individual externals).

Thoughts appreciated.

21 days later

the latest master and dev branches will automatically add the current path and projects/pd-externals to libpd's search path so that you can just drop a compiled external in there and it will work!

    21 days later

    hmmm.. doesn't seem to work for me!
    a compiled external in a project folder is seen, but when I move it to the folder projects/pd-external (which I created, as it wasn't there), it's not anymore..
    That's with Bela 0.2.

    Hm. That's right, I guess there was a typo in my post above (fixed now): it is projects/pd-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

      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!

      a month later

      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.

      2 months later

      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/.

      3 months later

      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.

      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.

      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.