Error trying to build a cross compiler setup for RtAudio in Ubuntu
by mahaju from LinuxQuestions.org on (#5QPP8)
I want to make a cross compiler for my program containing RtAudio (https://www.music.mcgill.ca/~gary/rtaudio/) code for raspberry pi zero, in Ubuntu in Pc. That is, I have a VM running Ubuntu 20.04. I want to write and compile my program using RtAudio inside this computer, and copy only the executable over to the raspberry pi and run it. I am not very familiar with cross compiling so please excuse any beginner misunderstandings or misuse of terminology.
I downloaded rtaudio-5.1.0.tar.gz from here: https://www.music.mcgill.ca/~gary/rtaudio/ (http://www.music.mcgill.ca/~gary/rta...o-5.1.0.tar.gz)
I have already created a gcc cross compiler for raspberry pi using the instructions given here: https://stackoverflow.com/a/58559140/1693203
I have verified that a basic hello world program can be compiled in the Ubuntu machine and executed in the raspberry pi zero board.
I am guessing that I need to build the RtAudio library using this cross compiler toolchain first, in order to start building programs for the raspberry pi in the Ubuntu machine.
After extracting rtaudio-5.1.0, I configure it using this command:
sudo ./configure --with-alsa CXX=/opt/cross-pi-gcc/bin/arm-linux-gnueabihf-g++ CPPFLAGS=-I/usr/include/ --host=arm
However, when I give the make command I get the following error:
Code:Making all in .
make[1]: Entering directory '/home/ubuntu2004/myfolder/source/audio/RtAudio/rtaudio-5.1.0'
CXX librtaudio_la-RtAudio.lo
In file included from /usr/include/ctype.h:39,
from /opt/cross-pi-gcc/arm-linux-gnueabihf/include/c++/8.3.0/cctype:42,
from /opt/cross-pi-gcc/arm-linux-gnueabihf/include/c++/8.3.0/bits/localefwd.h:42,
from /opt/cross-pi-gcc/arm-linux-gnueabihf/include/c++/8.3.0/string:43,
from RtAudio.h:65,
from RtAudio.cpp:44:
/opt/cross-pi-gcc/arm-linux-gnueabihf/include/bits/endian.h:2:3: error: #error "Never use <bits/endian.h> directly; include <endian.h> instead."
error "Never use <bits/endian.h> directly; include <endian.h> instead."
^~~~~
In file included from /usr/include/pthread.h:25,
from /opt/cross-pi-gcc/arm-linux-gnueabihf/include/c++/8.3.0/arm-linux-gnueabihf/bits/gthr-default.h:35,
from /opt/cross-pi-gcc/arm-linux-gnueabihf/include/c++/8.3.0/arm-linux-gnueabihf/bits/gthr.h:148,
from /opt/cross-pi-gcc/arm-linux-gnueabihf/include/c++/8.3.0/ext/atomicity.h:35,
from /opt/cross-pi-gcc/arm-linux-gnueabihf/include/c++/8.3.0/bits/basic_string.h:39,
from /opt/cross-pi-gcc/arm-linux-gnueabihf/include/c++/8.3.0/string:52,
from RtAudio.h:65,
from RtAudio.cpp:44:
/opt/cross-pi-gcc/arm-linux-gnueabihf/include/bits/endian.h:2:3: error: #error "Never use <bits/endian.h> directly; include <endian.h> instead."
error "Never use <bits/endian.h> directly; include <endian.h> instead."
^~~~~
In file included from /usr/include/alsa/asoundlib.h:31,
from RtAudio.cpp:7116:
/usr/include/unistd.h:1170:10: fatal error: bits/unistd_ext.h: No such file or directory
#include <bits/unistd_ext.h>
^~~~~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:612: librtaudio_la-RtAudio.lo] Error 1
make[1]: Leaving directory '/home/ubuntu2004/myfolder/source/audio/RtAudio/rtaudio-5.1.0'
make: *** [Makefile:712: all-recursive] Error 1"/opt/cross-pi-gcc/bin/" is the location of the cross compiler. What should I do to set everything up so that I can compile my program in the Ubuntu machine? I am not very experienced with cross compiling so I will try to give as much information as possible for my current setup. I can already build my code containing RtAudio library in the raspberry pi board, and installing RtAudio on the raspberry pi was pretty straight forward (basically just follow the instructions on the install.txt file)
Ubuntu machine:
Ubuntu version 20.04
gcc --version =>
Code:gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
(This is the built in gcc compiler for x86_64)cross compiler version =>
Code:/opt/cross-pi-gcc/bin/arm-linux-gnueabihf-gcc --version =>
arm-linux-gnueabihf-gcc (GCC) 8.3.0libasound2-dev was installed as
sudo apt-get install libasound2-dev
version=>
Code:libasound2-dev is already the newest version (1.2.2-2.1ubuntu2.4).Raspberry pi zero W board:
OS => latest raspberry pi OS
gcc --version=>
Code:gcc (Raspbian 8.3.0-6+rpi1) 8.3.0libasound2-dev version =>
Code:libasound2-dev is already the newest version (1.1.8-1+rpt1).Now I am guessing that the version of libasound2-dev is the issue here, based on the last error message generated by make. I am guessing libasound2-dev in the Ubuntu machine is for x86 processors, while the one in my raspberry pi is for ARM. So I need to somehow get the raspberry pi version of libasound2-dev in the Ubuntu machine and build RtAudio against that. Am I going about this the right way?
I downloaded rtaudio-5.1.0.tar.gz from here: https://www.music.mcgill.ca/~gary/rtaudio/ (http://www.music.mcgill.ca/~gary/rta...o-5.1.0.tar.gz)
I have already created a gcc cross compiler for raspberry pi using the instructions given here: https://stackoverflow.com/a/58559140/1693203
I have verified that a basic hello world program can be compiled in the Ubuntu machine and executed in the raspberry pi zero board.
I am guessing that I need to build the RtAudio library using this cross compiler toolchain first, in order to start building programs for the raspberry pi in the Ubuntu machine.
After extracting rtaudio-5.1.0, I configure it using this command:
sudo ./configure --with-alsa CXX=/opt/cross-pi-gcc/bin/arm-linux-gnueabihf-g++ CPPFLAGS=-I/usr/include/ --host=arm
However, when I give the make command I get the following error:
Code:Making all in .
make[1]: Entering directory '/home/ubuntu2004/myfolder/source/audio/RtAudio/rtaudio-5.1.0'
CXX librtaudio_la-RtAudio.lo
In file included from /usr/include/ctype.h:39,
from /opt/cross-pi-gcc/arm-linux-gnueabihf/include/c++/8.3.0/cctype:42,
from /opt/cross-pi-gcc/arm-linux-gnueabihf/include/c++/8.3.0/bits/localefwd.h:42,
from /opt/cross-pi-gcc/arm-linux-gnueabihf/include/c++/8.3.0/string:43,
from RtAudio.h:65,
from RtAudio.cpp:44:
/opt/cross-pi-gcc/arm-linux-gnueabihf/include/bits/endian.h:2:3: error: #error "Never use <bits/endian.h> directly; include <endian.h> instead."
error "Never use <bits/endian.h> directly; include <endian.h> instead."
^~~~~
In file included from /usr/include/pthread.h:25,
from /opt/cross-pi-gcc/arm-linux-gnueabihf/include/c++/8.3.0/arm-linux-gnueabihf/bits/gthr-default.h:35,
from /opt/cross-pi-gcc/arm-linux-gnueabihf/include/c++/8.3.0/arm-linux-gnueabihf/bits/gthr.h:148,
from /opt/cross-pi-gcc/arm-linux-gnueabihf/include/c++/8.3.0/ext/atomicity.h:35,
from /opt/cross-pi-gcc/arm-linux-gnueabihf/include/c++/8.3.0/bits/basic_string.h:39,
from /opt/cross-pi-gcc/arm-linux-gnueabihf/include/c++/8.3.0/string:52,
from RtAudio.h:65,
from RtAudio.cpp:44:
/opt/cross-pi-gcc/arm-linux-gnueabihf/include/bits/endian.h:2:3: error: #error "Never use <bits/endian.h> directly; include <endian.h> instead."
error "Never use <bits/endian.h> directly; include <endian.h> instead."
^~~~~
In file included from /usr/include/alsa/asoundlib.h:31,
from RtAudio.cpp:7116:
/usr/include/unistd.h:1170:10: fatal error: bits/unistd_ext.h: No such file or directory
#include <bits/unistd_ext.h>
^~~~~~~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:612: librtaudio_la-RtAudio.lo] Error 1
make[1]: Leaving directory '/home/ubuntu2004/myfolder/source/audio/RtAudio/rtaudio-5.1.0'
make: *** [Makefile:712: all-recursive] Error 1"/opt/cross-pi-gcc/bin/" is the location of the cross compiler. What should I do to set everything up so that I can compile my program in the Ubuntu machine? I am not very experienced with cross compiling so I will try to give as much information as possible for my current setup. I can already build my code containing RtAudio library in the raspberry pi board, and installing RtAudio on the raspberry pi was pretty straight forward (basically just follow the instructions on the install.txt file)
Ubuntu machine:
Ubuntu version 20.04
gcc --version =>
Code:gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
(This is the built in gcc compiler for x86_64)cross compiler version =>
Code:/opt/cross-pi-gcc/bin/arm-linux-gnueabihf-gcc --version =>
arm-linux-gnueabihf-gcc (GCC) 8.3.0libasound2-dev was installed as
sudo apt-get install libasound2-dev
version=>
Code:libasound2-dev is already the newest version (1.2.2-2.1ubuntu2.4).Raspberry pi zero W board:
OS => latest raspberry pi OS
gcc --version=>
Code:gcc (Raspbian 8.3.0-6+rpi1) 8.3.0libasound2-dev version =>
Code:libasound2-dev is already the newest version (1.1.8-1+rpt1).Now I am guessing that the version of libasound2-dev is the issue here, based on the last error message generated by make. I am guessing libasound2-dev in the Ubuntu machine is for x86 processors, while the one in my raspberry pi is for ARM. So I need to somehow get the raspberry pi version of libasound2-dev in the Ubuntu machine and build RtAudio against that. Am I going about this the right way?