How to use gcc 8 on haiku x86?

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.

1 Like

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.

1 Like

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
“”)
export ARCHSET=x86
setarch x86
;;
*) . $HOME/config/settings/bashrc
# whatever else you might normally do in profile
;;
esac

1 Like

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:

export PATH=/boot/system/bin/x86:$PATH

1 Like

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)

Sorry little late on the train ;).

But how do I do that permenent?

Switch to 64 bit? :wink:

You can put /system/bin/x86 in your PATH before the “main” bin directory.

But I agree with extrowerk, if you don’t use old BeOS apps, it’s better and simpler to use the 64bit version of Haiku.

One can put the setarch command in profile, right?

I like to have the option to use GobeProductive…

Add the “setarch x86” command to your bash profile, so you dont have to manually run it then. Or change your PATH variable as @PulkoMandy recommended.