[yocto] Forcing GCC version for native compilation

Burton, Ross ross.burton at intel.com
Thu Nov 22 02:32:34 PST 2018


On Thu, 22 Nov 2018 at 07:33, Teemu K <maillinglists18 at gmail.com> wrote:
> 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
options in preferred order:
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

Ross


More information about the yocto mailing list