LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-14-2021, 02:27 AM   #1
mahaju
Member
 
Registered: Nov 2011
Posts: 39

Rep: Reputation: Disabled
Error trying to build a cross compiler setup for RtAudio in Ubuntu


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.0
libasound2-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.0
libasound2-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?
 
Old 10-14-2021, 07:52 PM   #2
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Why not simply create another VM with aarch64 architecture and install the OS from the Pi there. Then compiling would be done on the arch it is destined for.

The QEMU/KVM vmm does this easily on Fedora.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting error while compiling gcc(c-compiler) cross compiler shubhampushpkar Linux From Scratch 4 08-05-2019 12:12 AM
No space left on device error with plenty of free INodes after cross compiler setup keptil Linux - General 3 01-18-2011 08:05 AM
My c compiler doesn't work after the cross-compiler installed heracles.cn Linux - Newbie 1 06-05-2007 03:55 AM
Cross compiler build enviroment terp4life2001 Linux - General 1 12-10-2005 11:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration