Saturday, 19 May 2018

Learning Linux | Linux from the command line -- Compiling your own code

Learning Linux | Linux from the command line -- Compiling your own code

There are those that will tell you that you're not a real Linux user until you've compiled code for yourself. I guess I'm probably one of them.
There are lots of reasons to do this. For us old school Linux guys, you didn't used to have a choice. Back in the day you just had to compile some code from source in order to get a working Linux system installed and running. Later you had some choice in the matter, but you still compiled some key system components and libraries so that you could heavily optimize the output binaries for your specific hardware. This was because computers were slower and more resource constrained and every little bit of performance you could wring out of them was welcome. The next stage was only having to compile your own kernel to support your hardware configuration. Then modular kernels happened and the days of having to compile anything were over.
Now it comes down to mostly two cases. One is compiling code you wrote yourself, in which case you don't need this tutorial. The other case is when you've found a piece of software you've just got to have but that isn't available for your Linux distro or hardware setup or is only available in source form.
So, when that happens, here you go.


Pro Tip: My personal formula for the "-j" option is:
nproc*2-1
So if you have a 4 core processor, use make -j7
And these days, systems are pretty fast so it doesn't hurt to throw -03 in the command line, or at least -02.
http://www.linuxandubuntu.com/home/basics-of-compiling-software-from-source-code-in-linux

No comments:

Post a Comment