When I type gcc -v, it showed gcc2. I found gcc8’s package file under packages. So gcc 8 is also installed. But how to use it?
You can use
setarch x86 command to change gcc version.
Is this change is permanent or just on the current season (lost when I exit the terminal)?
Change is limited to current shell session. It is lost when exit Terminal. Also it is possible to call
setarch x86 gcc, it will change gcc only for 1 command.
If considering putting a setarch command in config/settings/profile, note that setarch starts another shell, which for some reason also runs profile, which will run setarch, which will run profile, etc. ad infinitum.
So you’d want some kind of test, like
case $ARCHSET in
*) . $HOME/config/settings/bashrc
# whatever else you might normally do in profile
If you don’t run gcc2 applications from BeOS I’d just recommend using the 64 bit version of Haiku, where there is no gcc2.
If you really want to do this in your profile, it is in fact much simpler without using setarch:
I found my own solution: append -x86 to the binary name, e.g: gcc-x86 -v
Yeah, I only use x86 because it uses fewer memory than x86_64. Perhaps I should switch to x86_64 completely, the little ram different doesn’t worth.
As said you can use “setarch x86” to switch to gcc8, if you want to revert back to gcc2 (without closing the Terminal) just type “exit” on the command line and it will revert to gcc2 (on gcc2h)