Post by Burton, Ross Post by Teemu K
I have project made for Yocto 1.7, but I'd like to compile it on newer
Linux distribution that default GCC version is 5.x. GCC version itself
causes some problems, because some things have changed.
There is also GCC 4.8 available, but it's not called 'gcc', but 'gcc-4.8'.
The question is that is there way to force yocto use 'gcc-4.8' instead
of 'gcc'? I did some searching and couldn't find any options how to do
it. I tried to making link to ~/bin/gcc pointing gcc-4.8 and having
that first in PATH, but that didn't quite work. I'm guessing path got
re-set at some point.
And before someone says. Updating Yocto to solve problem is not
solution. System is being updated, but current system still needs to
be able to compile.
The modern solution is to set BUILD_CC and so on, see bitbake.conf.
Note that in such an old release this might not work as well as you'd
hope because I don't think it was fully tested. In which case your
1) Some distributions let you change what the default compiler, for
example /usr/bin/gcc might be a symbolic link you can just change.
2) PATH fiddling as you did. You'll most likely need to replace more
than just gcc, for example cpp.
3) Just mv /usr/bin/gcc to /usr/bin/gcc-5 (and cpp, and anything
else), and symlink gcc -> gcc-4.8
1) There is BUILD_CC also in this version of Yocto. Doesn't seem to do
anything. I modified poky/meta/conf/bitbake.conf for testing purposes
to have BUILD_CC pointing those 4.8 versions yet the sources are
compiled with 'gcc' not 'gcc-4.8' so either something else overrides
those settings and/or source packages ignore that setting.
2) I also tried making links go gcc/g++/cpp and adding them to PATH
first. This seemed to work, bit better, but now compilation failed to
/usr/bin/ld: skipping incompatible
/usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a when searching for -lgcc
Which is interesting since I can use the gcc-4.8 just fine manually
and it creates working binary.
3) /usr/bin/gcc is actually link to gcc-5, but I don't want to change
that because then it would be system wide change and I want to avoid
I'll dig bit deeper why the second option didn't work. Any other
suggestions are welcome as well.