If you want to install it as a local user
GNU GSRC provides an easy way to do so
Link: http://www.gnu.org/software/gsrc/
After configuration, simply specify the following commands:
cd gsrc
make -C pkg/gnu/gcc
make -C pkg/gnu/gcc install
The second step could also be changed to speed up for an N-core system:
make -C pkg/gnu/gcc MAKE_ARGS_PARALLEL="-jN"
Answer from DanielY on Stack Overflowc++ - Install gcc on linux with no root privilege - Stack Overflow
c++ - Build a Linux executable using GCC - Stack Overflow
Is installing GCC on Linux as complicated as I think it is?
Why GCC the linux compiler is being used for the Windows systems? What is the reason of its popularity?
Videos
If you want to install it as a local user
GNU GSRC provides an easy way to do so
Link: http://www.gnu.org/software/gsrc/
After configuration, simply specify the following commands:
cd gsrc
make -C pkg/gnu/gcc
make -C pkg/gnu/gcc install
The second step could also be changed to speed up for an N-core system:
make -C pkg/gnu/gcc MAKE_ARGS_PARALLEL="-jN"
You can run the configure script with the --prefix parameter: ../gcc-4.5.0/configure --prefix=/home/foo/bar. Since it is very likely that the c++ standard library is different then the one on your system, you have to set export LD_LIBRARY_PATH=/home/foo/bar/lib before you can start a program compiled by this compiler.
That executable is a "Linux executable" - that is, it's executable on any recent Linux system. You can rename the file to what you want using
rename a.out your-executable-name
or better yet, tell GCC where to put its output file using
gcc -o your-executable-name your-source-file.c
Keep in mind that before Linux systems will let you run the file, you may need to set its "executable bit":
chmod +x your-executable-name
Also remember that on Linux, the extension of the file has very little to do with what it actually is - your executable can be named something, something.out, or even something.exe, and as long as it's produced by GCC and you do chmod +x on the file, you can run it as a Linux executable.
To create an executable called myprog, you can call gcc like this:
gcc -c -o myprog something.c
You could also just rename the *.out file gcc generates to the desired name.
Disclaimer: I am not well versed at Linux at all. Please pardon my ignorance.
I'm trying to figure out how to install GCC onto my macbook running Ubuntu 16.04. However after reading through the 6 steps to install GCC outlined on the GCC website I am at a total loss. I understand maybe 50% of the words on these pages. There are so many prerequisites and so many software requirements and so many technical things you have to set up that there is basically no hope in me figuring this out unless I extensively google every other word within the instructions. I would like to install it myself without the use of some sort of installer, but if it's this complicated to do so then I may have quite a bit of googling to do.
My question is this. What are the general guidelines I need to know to install GCC on Linux? I'm not asking for a "step-by-step how-to" guide. I'd just like a general overview on how one goes about installing GCC on their own. I understand I need some required software installed, I need to check and see if my physical CPU is compatible (real confusing), I need figure out in what directory I want to install GCC in, I need to figure out how to build GCC (this is real confusing) and I need to figure out a whole lotta stuff that I don't even know about yet. Perhaps it isn't as hard as it seems. Maybe this way of installing GCC is hard mode that nobody does. Or maybe this is the standard way that everyone uses. I don't know and would greatly appreciate any help or advice you all may have. Thanks!
Did you installed "ruby-dev" package?
All you need is install packages from Ubuntu repositorie (using "apt-get", "aptitude", or any other package manager front-end). No need in downloading sources. Installing package will plcase all tour required headers and libraries in standard directories, so you will not have to deal with compiler keys.
And only if you do not have required packages in repos (or it is so old), you'll have to download sourcecode tarballs and INSTALL it (accordingly included in tarball instructions, often in file INSTALL).
-I /home/braga/ruby_source/ruby_1_8_7. Chances are that ruby.h lives in some subdirectory of that though, so you'll have to find it, and use the path to that directory though.