I think this is a bug in the 1.9 SDK: I added some things to the local.conf file
MACHINE ??= 't4240rdb-64b'
DISTRO ?= 'fsl-qoriq'
#PACKAGE_CLASSES ?= "package_rpm"
EXTRA_IMAGE_FEATURES = "debug-tweaks ssh-server-openssh package-management"
IMAGE_INSTALL_append = " openjdk-7-jre tcsh smartpm opkg cmake "
USER_CLASSES ?= "buildstats image-mklibs"
PATCHRESOLVE = "noop"
BB_DISKMON_DIRS = "\
STOPTASKS,${TMPDIR},1G,100K \
STOPTASKS,${DL_DIR},1G,100K \
STOPTASKS,${SSTATE_DIR},1G,100K \
ABORT,${TMPDIR},100M,1K \
ABORT,${DL_DIR},100M,1K \
ABORT,${SSTATE_DIR},100M,1K"
PACKAGECONFIG_append_pn-qemu-native = " sdl"
PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl"
ASSUME_PROVIDED += "libsdl-native"
CONF_VERSION = "1"
BB_NUMBER_THREADS = "2"
PARALLEL_MAKE = "-j 2"
DL_DIR = "/home/nxp/SDK/QorIQ-SDK-V1.9-20151210-yocto/downloads"
SSTATE_DIR = "/home/nxp/SDK/QorIQ-SDK-V1.9-20151210-yocto/sstate-cache"
INHERIT += "own-mirrors"
SOURCE_MIRROR_URL ?= "http://git.freescale.com/source/"
##SSTATE_MIRRORS = "file://.*/(.*)/(.*) file://${SSTATE_DIR}/native/\1/\2 \n"
SSTATE_PKG_SUFFIX = "txz"
SSTATE_PKG_TARZIPPROG = "xz"
ACCEPT_FSL_EULA = ""
# Parallelism Options
BB_NUMBER_THREADS = "3"
PARALLEL_MAKE = "-j 3"
DL_DIR = "/home/nxp/SDK/QorIQ-SDK-V1.9-20151210-yocto/downloads"
SSTATE_DIR = "/home/nxp/SDK/QorIQ-SDK-V1.9-20151210-yocto/sstate-cache"
INHERIT += "own-mirrors"
SOURCE_MIRROR_URL ?= "http://git.freescale.com/source/"
##SSTATE_MIRRORS = "file://.*/(.*)/(.*) file://${SSTATE_DIR}/native/\1/\2 \n"
# use xz to compress sstate
SSTATE_PKG_SUFFIX = "txz"
SSTATE_PKG_TARZIPPROG = "xz"
and ran "bitbake fsl-image-full", then installed the resulting image on a sata hard drive, booted my T4240RDB from it, and tried to compile the following source:
(file name tc.cpp):
#include <cmath>
#include <iostream>
using namespace std;
int main(){
cout<<"hello"<<endl;
return 0;
}
Here is the output of g++ -v tc.cpp:
imagenav@t4240rdb:~$ g++ -v tc.cpp
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/gcc/powerpc64-fsl-linux/4.9.2/lto-wrapper
Target: powerpc64-fsl-linux
Configured with: /home/jenkins/ci/iso-make/master/b4860qds-64b/build_b4860qds-64b/tmp/work-shared/gcc-4.9.2-r0/gcc-4.9.2/configure --build=x86_64-linux --host=powerpc64-fsl-linux --target=powerpc64-fsl-linux --prefix=/usr --exec_prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib64/gcc --datadir=/usr/share --sysconfdir=/etc --sharedstatedir=/com --localstatedir=/var --libdir=/usr/lib64 --includedir=/usr/include --oldincludedir=/usr/include --infodir=/usr/share/info --mandir=/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/home/jenkins/ci/iso-make/master/b4860qds-64b/build_b4860qds-64b/tmp/sysroots/b4860qds-64b --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --enable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=powerpc64-fsl-linux- --without-local-prefix --enable-target-optspace --enable-lto --enable-libssp --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=gnu --enable-linker-build-id --with-ppl=no --enable-checking=release --enable-cheaders=c_global --with-sysroot=/ --with-build-sysroot=/home/jenkins/ci/iso-make/master/b4860qds-64b/build_b4860qds-64b/tmp/sysroots/b4860qds-64b --with-native-system-header-dir=/home/jenkins/ci/iso-make/master/b4860qds-64b/build_b4860qds-64b/tmp/sysroots/b4860qds-64b/usr/include --with-gxx-include-dir=/usr/include/c++/4.9.2 --with-long-double-128 --enable-nls --enable-__cxa_atexit
Thread model: posix
gcc version 4.9.2 (GCC)
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc'
/usr/lib64/gcc/gcc/powerpc64-fsl-linux/4.9.2/cc1plus -quiet -v -D_GNU_SOURCE -D__unix__ -D__gnu_linux__ -D__linux__ -Dunix -D__unix -Dlinux -D__linux -Asystem=linux -Asystem=unix -Asystem=posix tc.cpp -quiet -dumpbase tc.cpp -auxbase tc -version -o /tmp/ccnS6lCg.s
GNU C++ (GCC) version 4.9.2 (powerpc64-fsl-linux)
compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "usr/include/c++/4.9.2"
ignoring nonexistent directory "usr/include/c++/4.9.2/powerpc64-fsl-linux"
ignoring nonexistent directory "usr/include/c++/4.9.2/backward"
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib64/gcc/powerpc64-fsl-linux/4.9.2/../../../../powerpc64-fsl-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib64/gcc/powerpc64-fsl-linux/4.9.2/include
/usr/lib64/gcc/powerpc64-fsl-linux/4.9.2/include-fixed
/usr/include
End of search list.
GNU C++ (GCC) version 4.9.2 (powerpc64-fsl-linux)
compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version 3.1.2, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 63db6eac369c397424f29967693724f9
tc.cpp:1:20: fatal error: iostream: No such file or directory
#include <iostream>
^
compilation terminated.
You can see it's got some sort of misconfiguration in the search paths for the includes. Is this a bug? I don't see how I did anything that could cause this problem.
Quick workaround: use double slash for sysroot.
g++ --sysroot=// -v -o tc tc.cpp
Issue of broken sysroot for toolchains that have been configured with sysroot of / was discussed here:
Re: [patch] avoid '//' prefixes when sysroot is set to '/'
But that patch was not applied for gcc recipes in meta-freescale (sources/meta-freescale/recipes-devtools/gcc)
I see that one part of that patch is applied in poky upstream, though (sources/poky/meta/recipes-devtools/gcc/gcc-4.9/0040-fix-g++-sysroot.patch).
I eventually managed to apply the patch to the compiler and rebuild the system image for my development machine. Seems like this patch ought to eventually be applied by default - perhaps in the next SDK rev?
In the meantime, to avoid patching and rebuilding the toolchain, I created a wrapper script on the target. The script below automates the process:
#!/bin/sh
set -x
set -e
if [ -e "/usr/bin/powerpc64-fsl-linux-g++.real" ] ; then
exit 0
fi
if [ ! -e "/usr/bin/powerpc64-fsl-linux-g++" ] ; then
exit 1
fi
cat <<"__EOF__" >"/usr/bin/powerpc64-fsl-linux-g++.wrapper"
#!/bin/sh
exec "/usr/bin/powerpc64-fsl-linux-g++.real" --sysroot=//// "$@"
__EOF__
chmod a+x "/usr/bin/powerpc64-fsl-linux-g++.wrapper"
mv "/usr/bin/powerpc64-fsl-linux-g++" "/usr/bin/powerpc64-fsl-linux-g++.real"
mv "/usr/bin/powerpc64-fsl-linux-g++.wrapper" "/usr/bin/powerpc64-fsl-linux-g++"
This allows me to compile with C++ compiler without passing the sysroot parameter to the CXX variable for the build system.
Trying to re-install gcc using smart. I have lighttpd serving the rpms, configured smart to see the channels, but when I ask smart to commit the re-install, it says "rpm unavailable for download".
On a whim, tried "smart --shell" and used the "check" command as "check gcc" and got the following:
smart> check gcc
Unsatisfied dependency: gcc-4.9.2-r0@lib32_ppce6500 requires libmpc.so.3
Unsatisfied dependency: gcc-4.9.2-r0@lib32_ppce6500 requires libdl.so.2(GLIBC_2.1)
Unsatisfied dependency: gcc-4.9.2-r0@lib32_ppce6500 requires ld.so.1(GLIBC_2.3)
Unsatisfied dependency: gcc-4.9.2-r0@lib32_ppce6500 requires libz.so.1
Unsatisfied dependency: gcc-4.9.2-r0@lib32_ppce6500 requires libc.so.6(GLIBC_2.11)
Unsatisfied dependency: gcc-4.9.2-r0@lib32_ppce6500 requires libgmp.so.10
Unsatisfied dependency: gcc-4.9.2-r0@lib32_ppce6500 requires libdl.so.2
Unsatisfied dependency: gcc-4.9.2-r0@lib32_ppce6500 requires ld.so.1
Unsatisfied dependency: gcc-4.9.2-r0@lib32_ppce6500 requires libdl.so.2(GLIBC_2.0)
Unsatisfied dependency: gcc-4.9.2-r0@lib32_ppce6500 requires libmpfr.so.4
Do I need to install this lib32_ppce6500 stuff?