SUMMARY
I am unable to use an Arago-built SDK to compile C++ programs that reference the STL.
I had the impression that I was supposed to just be able to call ${CXX} and it would work. But it fails if I reference a STL header. Is there another switch required to specify the path to the STL headers?
BACKGROUND
I have built a custom SDK using the command line
MACHINE=am64xx-evm ARAGO_RT_ENABLE=1 bitbake multiconfig:segB1:image-lseb -c populate_sdk
It seems to work fine. I then install the SDK to a folder in my home directory:
cd ~/tisdk/build/arago-tmp-external-arm-glibc/deploy/sdk
sudo ./arago-2021.09-toolchain-2021.09.sh
And I install the SDK to the folder ~/lsebsdk. It seems to install fine.
PROBLEM: C++ STL Compile Failure
I start a new shell and source the SDK's environment setup script:
. /home/brad/lsebsdk/environment-setup-aarch64-linux
It seems to work fine - printenv shows the expected settings.
But when I try to compile a file that includes C++ STL headers, it fails. This is the simplest example:
echo '#include <vector>' | ${CXX} -v -E -
After printing out the various settings, it fails with:
<stdin>:1:10: fatal error: vector: No such file or directory
INVESTIGATIONS
When I investigate the -v output, I see this (color highlights mine):
COLLECT_GCC_OPTIONS='-v' '-E' '-shared-libgcc' '-mlittle-endian' '-mabi=lp64'
/home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../libexec/gcc/aarch64-none-linux-gnu/9.2.1/cc1 -E -quiet -v -iprefix /home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/aarch64-none-linux-gnu/9.2.1/ -isysroot /home/brad/lsebsdk/sysroots/aarch64-linux - -mlittle-endian -mabi=lp64
ignoring nonexistent directory "/home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/aarch64-none-linux-gnu/9.2.1/../../../../aarch64-none-linux-gnu/include"
ignoring duplicate directory "/home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/../../lib/gcc/aarch64-none-linux-gnu/9.2.1/include"
ignoring nonexistent directory "/home/brad/lsebsdk/sysroots/aarch64-linux/usr/local/include"
ignoring duplicate directory "/home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/../../lib/gcc/aarch64-none-linux-gnu/9.2.1/include-fixed"
ignoring nonexistent directory "/home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/../../lib/gcc/aarch64-none-linux-gnu/9.2.1/../../../../aarch64-none-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/aarch64-none-linux-gnu/9.2.1/include
/home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/aarch64-none-linux-gnu/9.2.1/include-fixed
/home/brad/lsebsdk/sysroots/aarch64-linux/usr/include
As far as I can tell, the issue is that there is no "include" folder under the referenced directory - only bin and lib:
brad@MSI:~$ cd /home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/bin/../lib/gcc/aarch64-none-linux-gnu/9.2.1/../../../../aarch64-none-linux-gnu/
brad@MSI:~/lsebsdk/sysroots/x86_64-arago-linux/usr/aarch64-none-linux-gnu$ ls
bin lib
Sleuthing a bit, if one follows the "-isysroot" path, one does find an include folder with "vector" in it:
brad@MSI:~$ cd /home/brad/lsebsdk/sysroots/aarch64-linux
brad@MSI:~/lsebsdk/sysroots/aarch64-linux$ ls
bin board-support boot dev etc home include lib media mnt proc run sbin sys tmp usr var
brad@MSI:~/lsebsdk/sysroots/aarch64-linux$ cd usr/include/c++/9.2.1/
brad@MSI:~/lsebsdk/sysroots/aarch64-linux/usr/include/c++/9.2.1$ ls vector
vector
The problem appears to be that C++ is searching for its STL headers along the -iprefix path rather than the -isysroot path.
The compiler seems to be correctly searching for C headers along the -isysroot path /home/brad/lsebsdk/sysroots/aarch64-linux/usr/include. But it is searching for the C++ STL headers along the -iprefix path.
So it would appear that the compiler somehow needs to be told "look for your STL headers under -isysroot rather than -iprefix", OR the SDK should include a copy of (or symlink to) the sysroot STL headers found beneath the -iprefix path at
/home/brad/lsebsdk/sysroots/aarch64-linux/usr/include/c++/9.2.1
in the folder
/home/brad/lsebsdk/sysroots/x86_64-arago-linux/usr/aarch64-none-linux-gnu/usr/include/c++/9.2.1
Am I doing something wrong? I had the impression that I was supposed to just be able to call ${CXX} and it would work. But it doesn't. Is there another switch to specify the path to the STL headers? Is this a bug in the Arago SDK build? Is there a workaround?
Thanks,
Brad