What is in these Makefiles? Why don't you use the one that comes with the project?

a month later

Hello, I'm having a few issues compiling pd externals. I've worked through this post without success and I eventually found this very helpful guide: https://forum.bela.io/d/580-compiling-pd-externals-a-guide which clears most things up.

However, I'm still getting errors - "make: *** No targets specified and no makefile found. Stop" for [cyclone], [comport] and [list-abs] objects. I read the post above on [cyclone] and have taken the following steps:

  • Updated Bela code
  • Downloaded the PD fork and copied it into /root/pure-data
  • then went back to Bela/projects/pd-externals/externals/cyclone and tried
    'make PDINCLUDEDIR=/root/pure-data/src/ PDLIBDIR=/root/Bela/projects/pd-externals install'

But I'm getting "make: *** No rule to make target "install". Stop.

Any ideas?

    Great, thanks. Managed to successfully compile [cyclone] and [list-abs] objects now.

    Having a slight issue with the cyclone -- coll object though. It turns the project window blank (although it doesn't say 'couldn't create' in the console). Not sure what's going on with it.

    Also I haven't managed to compile the [comport] object. I can't find a Makefile for it. But in the readme file it says:

    compile:
    
     Unix (Linux):   
      make pd_linux,  make pd_irix5, make pd_irix6, make pd_darwin
      should produce a comport.pd_linux, .... 

    this is all new to me so not really sure what to do with that... do I still need a makefile from somewhere?

      Where is the source code for the [comport] object?

      emerson Having a slight issue with the cyclone -- coll object though. It turns the project window blank (although it doesn't say 'couldn't create' in the console). Not sure what's going on with it.

      I cannot reproduce this. Can you send the Pd file?

      Ok, so now got the source code for [comport] from the puredata.info site, which has a make file in it. Copied the new comport folder to the pd-externals folder on Bela but getting:

      Makefile:191: recipe for target 'comport.o' failed
      make: *** [comport.o] Error 1
      root@bela:~/Bela/projects/pd-externals/pd-comport# make PD_INCLUDE=/root/Bela/projects/pd-externals
       -I"/root/Bela/projects/pd-externals/pd" -Wall -W -g -DPD -DVERSION='"0.2"' -fPIC -O6 -funroll-loops -fomit-frame-pointer -o "comport.o" -c "comport.c"
      comport.c:24:18: fatal error: m_pd.h: No such file or directory
       #include "m_pd.h"
                        ^
      compilation terminated.
      Makefile:191: recipe for target 'comport.o' failed 

      for whatever I try. It says to use PD_INCLUDE = $(PD_PATH)/include in the make file.

      I tried:
      make PD_INCLUDE=/usr/local/include/libpd/
      make PD_INCLUDE=/root/Bela/projects/pd-externals install
      make PD_INCLUDE=/usr/local/include/libpd PDLIBDIR=/root/Bela/projects/pd-externals install
      make PD_INCLUDE=/root/pure-data/src/ PDLIBDIR=/root/Bela/projects/pd-externals install
      make PDINCLUDEDIR=/root/pure-data/src/ PDLIBDIR=/root/Bela/projects/pd-externals install

      This is what's in the [comport] folder:

      CHANGES.txt  Makefile    comport-help.pd  comport-stress-test.pd  comport.dsp  
      comport.pd_darwin LICENSE.txt  README.txt  comport-meta.pd  comport.c               
      comport.dsw  makefile_win

      can you link to the source code? I struggle to find it on the website. Is it the "get comport for all platforms" download link from https://puredata.info/downloads/comport/releases/0.2 ?

      Inspecting the Makefile in there, there is one line:

      CFLAGS = -I"$(PD_INCLUDE)/pd" -Wall -W -g

      so it seems to append /pd to whatever value you give to PD_INCLUDE=. I'd recommend you edit the Makefile and remove that /pd so you can pass the correct path straight from the command line.

      Additionally, PDLIBDIR= is not taken into consideration by this Makefile, and the paths used for the install target are a bit complicated. I'd recommend you just manually copy the generated comport.pd_linux file to ~/Bela/projects/pd-externals/.

        Here's the pd patch for the cyclone/coll object. I put the Coll object in the patch first, if that makes a difference? Sorry to post so many probs!

        #N canvas 771 243 450 300 10;
        #X obj 18 161 cyclone/coll;
        #C restore;
        #X obj 16 192 print coll;
        #X obj 34 24 loadbang;
        #X msg 36 49 in 11;
        #X obj 37 74 s bela_setDigital;
        #X obj 70 102 r bela_digitalIn11;
        #X msg 68 126 next;
        #X msg 19 128 1;
        #X connect 0 0 1 0;
        #X connect 2 0 3 0;
        #X connect 2 0 7 0;
        #X connect 3 0 4 0;
        #X connect 5 0 6 0;
        #X connect 6 0 0 0;
        #X connect 7 0 0 0;

        Here's what happens when I run the patch in the IDE:

        alt text

        How do you generate that patch? With Pd vanilla? Pd vanilla does not recognize the #C restore; line, so maybe that is what is crashing the preview in the browser? Either way, it's not a big deal: you only miss the preview, but the patch will still run fine. The two things are separate.

          giuliomoro Yes that's the link to the source code I used. Thanks for the advice on the make file, I'll give that a try.

            giuliomoro Ha, good to know, thanks. I thought the patch wasn't running properly because it wasn't printing the coll data to the console....but just figured out it's because I forgot to include the .txt file in the Bela project!! All sorted now, thanks.

            emerson
            Incidentally, this sort of variability between makefiles is exactly what makes it hard to write a comprehensive, one-size-fits-all Pd externals compiling guide: you will often have to rely in manual inspection to accommodate for these sort of differences

            2 months later

            I followed their instructions:

            You need build-essentials, header files for puredata, libjson-c, libcurl4, liboauth. If you have Debian or a derivative (e.g. Ubuntu, Linux Mint), you can install the build utils and needed headers with apt-get install build-essential puredata-dev libjson-c-dev libcurl4-openssl-dev liboauth-dev. If you are not root, prefix the command with sudo.

            If the board is connected to the internet, this is straightforward. Just run apt-get install build-essential libjson-c-dev libcurl4-openssl-dev liboauth-dev (note that I removed puredata-dev as we already have libpd on the board). If it is not, I just put together this script the other day that will do just that (tested on Mac, should work on Linux, possibly on Windows): https://github.com/giuliomoro/bela-random/blob/master/cross-apt-get-install.sh . Using this script, I run

            ./cross-apt-get-install.sh libjson-c-dev libcurl4-openssl-dev liboauth-dev

            make sure this is successful.

            Back to their instructions:

            Drop the sources in a directory and run make. You will get files with a suffix of pd_linux for each object (json-decode.pd_linux, json-encode.pd_linux, rest.pd_linux, oauth.pd_linux). These are needed to use the library.

            So I clone the repo on the host:

            git clone --recursive https://github.com/residuum/PuRestJson

            (I need the --recursive because it has some subrepo) and then I copy this across to the board:

            scp -r PuRestJson root@192.168.7.2

            Then I go back on the board and, as instructed, I run make:

            ssh root@192.168.7.2 

            (Note that all the commands after this will be run on the board.)

            cd PuRestJson
            make

            in less than one minute, I obtain a message : target all in lib purest_json completed. This gives me hope. Then I run ls and I see that the .pd_linux files have indeed been generated. Seems like success!

            Testing:
            I have no idea what these files are supposed to do, so I just make sure they get loaded.

            First: copy somewhere where they can be found. According to the Bela wiki I can just copy these files to the ~/Bela/projects/pd-externals folder in order for al the projects to be able to discover them. So, first I create such folder:

            mkdir -p ~/Bela/projects/pd-externals

            and then I copy the files there:

            cp ~/PuRestJson/*.pd_linux ~/Bela/projects/pd-externals

            Last, I create a Pd patch on my computer which uses these externals, then create a new Pd project in the Bela IDE, and I drag the newly created patch on it. I run the project and... there are no errors on the console, which means everything went fine: the objects are correctly loaded! There are also some lines that show that they were indeed loaded correctly.

            alt text

            Now, whether they work or not, I have no idea. You shall find out. If they don't do things cleverly and they run non-realtime code in the audio thread (as it's commonplace in Pd) then bad news: you may have to rewrite part of them. But maybe they don't and everything is nice!

            (It really takes 5 minutes to do all the above. It took me about 30 minutes writing it down, though).

            • cmm likes this.

            Thanks so much for going through this. Without an internet connection on the board I was a bit stuck, so looks like a great solution. I've just tried to run your script from my mac but I get the error message: xargs: wget: No such file or directory. Have I missed something?

            I guess you don't have wget installed. I rewrote it to use curl instead. Pull the updated version and try again.

            • cmm replied to this.

              That seemed to work, but then I received the following errors during the first process:

              dpkg-deb: error: '/tmp/pkgs//libcurl4-openssl-dev_7.52.1-5+deb9u4_armhf.deb' is not a debian format archive
              dpkg: error processing archive /tmp/pkgs//libcurl4-openssl-dev_7.52.1-5+deb9u4_armhf.deb (--install):
              subprocess dpkg-deb --control returned error exit status 2

              and then, a while later:

              dpkg: dependency problems prevent configuration of liboauth-dev:
              liboauth-dev depends on libcurl4-gnutls-dev | libcurl4-dev; however:
              Package libcurl4-gnutls-dev is not installed.
              Package libcurl4-dev is not installed.

              dpkg: error processing package liboauth-dev (--install):
              dependency problems - leaving unconfigured
              Processing triggers for libc-bin (2.24-11+deb9u3) ...
              Processing triggers for man-db (2.7.6.1-2) ...
              Errors were encountered while processing:
              /tmp/pkgs//libcurl4-openssl-dev_7.52.1-5+deb9u4_armhf.deb
              liboauth-dev

              I tried the next steps anyway just in case, no dice. Would it be worth trying to reinstall wget and going back to your original script?

                giuliomoro actually, is there any chance I could grab those compiled versions from you please? I feel like it'd be worthwhile trying this process with a clear head, but would really appreciate seeing if they work before I try other options for current project.

                  Feel like I'm so close! I found that connecting Bela to the internet was much easier than I imagined, so I ran apt-get update just in case, and followed your instructions directly over ssh. Now when I try to make it, I get the following error:

                  '''
                  ls: cannot access '/m_pd.h': No such file or directory
                  ++++ info: using Makefile.pdlibbuilder version 0.5.0
                  pd-lib-builder/Makefile.pdlibbuilder:744: Where is Pd API m_pd.h? Do 'make help' for info.
                  ++++ info: making target all in lib purest_json
                  ++++ info: making src/json-encode.o in lib purest_json
                  cc -DPD -I "" -DUNIX -fPIC -DVERSION='"1.4.2"' -I"src/uthash/src" -std=c99 -Wall -Wextra -Wshadow -Winline -Wstrict-aliasing -O3 -ffast-math -funroll-loops -fomit-frame-pointer -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard -o src/json-encode.o -c src/json-encode.c
                  In file included from src/json-encode.c:31:0:
                  src/json-encode.h:27:18: fatal error: m_pd.h: No such file or directory
                  #include "m_pd.h"
                  ^
                  compilation terminated.
                  pd-lib-builder/Makefile.pdlibbuilder:899: recipe for target 'src/json-encode.o' failed
                  make: *** [src/json-encode.o] Error 1
                  '''

                  I can see m_pd.h referenced further up this thread but not sure where to go from here - ran the help, tried adding same PD_INCLUDE lines as emerson.

                    cmm could grab those compiled versions from you please? I

                    that wouldn't work: you need the dependencies to be installed for those to work.

                    cmm dpkg-deb: error: '/tmp/pkgs//libcurl4-openssl-dev_7.52.1-5+deb9u4_armhf.deb' is not a debian format archive

                    So what happened here is that the download failed because the URL of the package is obsolete (and the board - who we trust to provide the URLs) does not know about it because it's not connected to the internet. wget would have not helped.