i recently got Oracle Solaris on my VM to test some code on it, i was unable to install gcc since i dont really know how, i googled alot but all info is about oracle compile
I'll quote the answer from unix.stackexchange.com.
On Solaris 11 gcc
is not installed by default. Normally you'll want more than just the compiler itself so my answer will include all the usual suspects for building open source software on Solaris that you've downloaded from somewhere in source code format.
By far the easiest is to use IPS to install it using the commands below (while being root or other superuser):
pkg install pkg://solaris/developer/build/gnu-make \
pkg://solaris/developer/build/make \
pkg://solaris/developer/gcc \
pkg://solaris/system/header \
pkg://solaris/developer/build/autoconf \
pkg://solaris/developer/build/automake
(I use fully qualified package names here, that is not really necessary)
Note that some of the packages are available in the official repo in various versions. If you just reference developer/gcc
then you'll at the time of writing this get GNU C v4.8.2, but you may explicitly ask for a prior version, e.g. by using package name such as developer/gcc-45
.