Hi,

I'm getting very interested in using Eclipse to compile my Bela projects on my laptop computer! I'm getting an increasingly complex setup, so currently a clean build of my Bela project takes far to long now....

I have tried to setup the
https://github.com/BelaPlatform/Bela/wiki/Compiling-Bela-projects-in-Eclipse
on Ubuntu running in VirtualBox..

I can compile the project but I get some errors about objects not being found... and some of the include-paths is greyed out. I would really appreciate a tutorial on how to setup cross-compilation that goes in-depth so that i will understand how to include a missing library, shared object in Eclipse...

Maybe the guide and/or Eclipse-Bela-Project simply needs an update ?

Best,
Hjalte

I need a bit more details as to what went wrong to be able to help (i.e.: what errors are you getting?) ... there is a suggestion of mine here on how to solve some problems that may arise. @AndyCap did the original Eclipse tutorial but it hasn't been brought up to date.

@HjalteBestedMoeller

As for what I do, I use distcc to shorten compile times to a reasonable time, and not having to worry (too much) about the cross-compile toolchain. This is explained in some detail here, and it's even simpler with image v0.3.8 and above : there is no need to do any of the preparation on Bela listed there. You only need to create a /root/Bela/CustomMakefileTop.in which contains just this line:

DISTCC := 1

Also, the step about setting up distcc on the host is actually easier than what explained there for macos ( you can just install it with brew), but on Windows you may have to build it from source?

    15 days later

    giuliomoro Finally got the time to try this out ! It's working very well with my ubuntu installation, got my clean compile time down from around 30 minutes to around 2.5 minutes 🙂 Nice !

    That's a game changer! 😃

    Once in a while I get the following messsage:

    distcc[5429] (dcc_build_somewhere) Warning: failed to distribute and fallbacks are disabled

    If I then refresh the IDE and make a change to a file it usually starts working again...

    Best,
    Hjalte

    13 days later

    For Windows 10 Users I would recommend using WSL (Windows Subsystem for Linux).

    Setup is fairly simple!

    Step 1: Enable and setup WSL

    When Windows is updated start a Windows PowerShell in admin mode and execute the following command to enable WSL.

    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

    Restart your computer when prompted.

    After WSL is enabled go to Microsoft Store, find Ubuntu 18.04 and install it (you do not have to login, even if asked).

    When installed, press Start in the Microsoft Store and enter your username and password for the WSL. WSL is now ready to be used.

    Step 2: Install Needed Packages in WSL

    sudo apt update
    sudo apt install autoconf clang-3.9
    sudo apt install distcc

    Step 3: Setting up in WSL

    Create the folder ~/arm or similar (if you choose something else, then modify the scripts that follow accordingly):

    mkdir -p ~/arm

    On the host, create the following script in /usr/local/bin/clang-3.9-arm:

    #!/bin/bash
    clang-3.9 -target armv7l-unknown-linux-gnueabihf --sysroot ~/arm $@

    Create the following script in /usr/local/bin/clang++-3.9-arm:

    #!/bin/bash
    clang++-3.9 -target armv7l-unknown-linux-gnueabihf --sysroot ~/arm $@

    Make them executable:

    sudo chmod +x /usr/local/bin/clang-3.9-arm
    sudo chmod +x /usr/local/bin/clang++-3.9-arm

    Setup on WSL host is now done.

    Step 4: Setting up on Bela

    If you are using Bela Image 0.3.8a or later, simply do the following to prepare for Cross Compilation

    As giuliomoro says above, on Bela create a /root/Bela/CustomMakefileTop.in which contains just this line:

    DISTCC := 1

    When using on windows you need to edit the IP adresse of the Host in the folowing files:

    /usr/local/bin/distcc-clang
    /usr/local/bin/distcc-clang++

    i.e. change the line export DISTCC_HOSTS=192.168.7.1 to export DISTCC_HOSTS=192.168.6.1 or whatever you host IP is as seen from Bela.

    If using an older image follow the (Bela) instructions here:
    https://forum.bela.io/d/724-distcc-distributed-compilation-with-bela

    Step 5: Using DistCC

    Before you can compile using distcc you need to start the distcc deamon:

    distccd --verbose --no-detach --daemon --allow 192.168.6.2 --log-level debug --log-file ~/distccd.log

    Now you're ready to compile using distcc using Windows Subsystem for Linux 🙂

    Step 6: Compile projects as usual in IDE or from command line

    Hope that is helpful for someone 🙂

    When using distcc it can utilize the parallelization feature of make, my clean build is about 15 % faster if I build with -j8, i.e.

    make -j8 PROJECT=myProject Bela

    is there anyway to specify this so that the Ide will compile in parallel ?

    Best,
    Hjalte

    good point, however I rarely do that. There are two main reasons:
    - distcc does part of the job (preprocessing) on Bela and part of the job (compiling) on the host. Because ultimately there are only so many jobs that can run at once on Bela itself, it may choke if you give it a number of jobs that is too large. Have you tried smaller values of j ? You may find a sweet spot that is lower than 8.
    - I am not 100% that the Makefile is designed in such a way that it can parallelise building a project and I am afraid it may build a binary that contains part old part new files. I don't remember if this actually happened to me, but if I were you, I'd double check, as weird "unexplicable" bugs could arise from this

    Ok, I see..

    Everything seems to work fine, however I think I'll stick with building without -j parallelization. It's not worth risking weird "unexplicable" bugs to arise. Thnx for your support as always 🙂

      2 years later

      I'll cross-post from the gists, with informational current mileage:

      """
      Thanks for the notes.
      At the moment, for macOS Monterey 12.5.1, distcc is provided by Homebrew, Clang provided on the LLVM site works, and Bela image v0.3.8g includes all of the setup stated above. So, I didn't need to build anything in preparation, just set up the server-side stand-in executables pointing to the clang executables and alter IP addresses in all scripts since my Bela is on my LAN. I'm able to compile udp-client.c remotely. Will try some other things.
      """

      If it would help anyone I can jot down specific HOWTO-recipe-like notes for this case.

        HjalteBestedMoeller Everything seems to work fine, however I think I'll stick with building without -j parallelization. It's not worth risking weird "unexplicable" bugs to arise.

        Now fixed in dev. Finally we can use -j without fear even with distcc

        plate-of-shrimp If it would help anyone I can jot down specific HOWTO-recipe-like notes for this case.

        Not sure I understand.... Tell me more?

          giuliomoro Hi, sorry, I should stay quiet, there's nothing wrong. It's just that setting up distcc for Bela and Monterey takes fewer steps than the current Gists indicate, eg. you don't have to build distcc. Any HOWTO is shorter. Again I'm reporting that things WORK!