banner



How To Install At&t U Verse Router

How to install software from source code

Brief: This detailed guide explains how to install a program from source code in Linux and how to remove the software installed from the source code.

One of the greatest strength of your Linux distribution is its package manager and the associated software repository. With them, you have all the necessary tools and resources to download and install new software on your computer in a completely automated way.

But despite all their efforts, the parcel maintainers cannot handle each and every apply cases. Nor tin they package all the software available out in that location. And then there are still situations where yous will take to compile and install new software by yourself. As for me, the most mutual reason, past far, I have to compile some software is when Ineed to run a very specific version, or modify the source code by the utilise of some fancy compilation options.

If yourneeds belong to the latter category, chances are you already know what to do. But, for the vast majority of Linux users, compiling and installing software from the source code for the beginning fourth dimension might look like an initiation ceremony: somewhat frightening; merely with the promise of entering a new world of possibilities and a identify of prestige in a privileged community.

[irp posts="13491″ proper name="How To Install And Remove Software In Ubuntu"]

A. Installing software from source code in Linux

And that'southward exactly what nosotros volition do here. For the purpose of this article, let'south say I need to install NodeJS eight.one.i on my organization. That version exactly. A version which is not bachelor from the Debian repository:

            sh$ apt-cache madison nodejs | grep amd64     nodejs | 6.xi.one~dfsg-1 | http://deb.debian.org/debian experimental/chief amd64 Packages     nodejs | four.8.2~dfsg-1 | http://ftp.fr.debian.org/debian stretch/master amd64 Packages     nodejs | 4.8.2~dfsg-1~bpo8+ane | http://ftp.fr.debian.org/debian jessie-backports/main amd64 Packages     nodejs | 0.ten.29~dfsg-two | http://ftp.fr.debian.org/debian jessie/main amd64 Packages     nodejs | 0.10.29~dfsg-one~bpo70+i | http://ftp.fr.debian.org/debian wheezy-backports/primary amd64 Packages          

Now, installing NodeJs on Ubuntu or Debian is pretty simple if you do it with the parcel manager. Just let'due south do information technology via the source lawmaking.

Step 1: Getting the source code from GitHub

Like many open-source projects, the sources of NodeJS tin exist found on GitHub: https://github.com/nodejs/node

And then, permit's go directly there.

The NodeJS official GitHub repository

If you're not familiar with GitHub, git or whatever other version command system worth mentioning the repository contains the electric current source for the software, every bit well every bit a history of all the modifications made through the years to that software. Eventually up to the very first line written for that project. For the developers, keeping that history has many advantages. For us today, the main one is we will be able to become the sources from for the project as they were at whatsoever given point in time. More than precisely, I will be able to go the sources equally they were when the eight.1.one version I want was released. Even if there were many modifications since then.

Choose the v8.1.1 tag in the NodeJS GitHub repository

On GitHub, yous can use the "co-operative" button to navigate between different versions of the software. "Branch" and "tags" are somewhat related concepts in Git. Basically, the developers create "branch" and "tags" to keep track of important events in the project history, similar when they beginning working on a new feature or when they publish a release. I will not get into the details here, all you need to know is I'g looking for the version tagged "v8.1.i"

The NodeJS GitHub repository as it was at the time the v8.1.1 tag was created

Subsequently having chosen on the "v8.1.1" tag, the page is refreshed, the nearly obvious change existence the tag now appears as part of the URL. In addition, you will notice the file change date are different as well. The source tree you are now seeing is the ane that existed at the fourth dimension the v8.ane.1 tag was created. In some sense, y'all can recall of a version control tool like git as a fourth dimension travel auto, assuasive you to go back and forth into a project history.

NodeJS GitHub repository download as a ZIP button

At this betoken, we tin can download the sources of NodeJS 8.one.i. You tin can't miss the big blue button suggesting to download the ZIP annal of the projection. Equally for me, I volition download and extract the Zippo from the command line for the sake of the explanation. But if y'all adopt using a GUI tool, don't hesitate to do that instead:

            wget https://github.com/nodejs/node/archive/v8.1.ane.zip unzip v8.i.ane.zip cd node-eight.1.1/          

Downloading the ZIP archive works great. Just if you want to exercise information technology "like a pro", I would suggest using directly the git tool to download the sources. It is not complicated at all— and it will exist a overnice beginning contact with a tool yous will often encounter:

            # first ensure git is installed on your arrangement sh$ sudo apt-go install git # Make a shallow clone the NodeJS repository at v8.1.1 sh$ git clone --depth 1 \               --branch v8.1.1 \               https://github.com/nodejs/node sh$ cd node/          

By the way, if you have an issue, only consider the first function of thisarticle equally a general introduction. Later I have more detailed explanations for Debian- and RedHat-based distributions in gild to assistance y'all troubleshoot mutual bug.

Anyway, whenever you lot downloaded the source using git or as a Nix archive, you should at present have exactly the same source files in the current directory:

            sh$ ls android-configure  Edifice.md            common.gypi      doc            Makefile   src AUTHORS            CHANGELOG.doc           configure        GOVERNANCE.medico  node.gyp   exam criterion          CODE_OF_CONDUCT.doctor     CONTRIBUTING.md  lib            node.gypi  tools BSDmakefile        COLLABORATOR_GUIDE.md  deps             LICENSE        README.physician  vcbuild.bat          

Step 2: Understanding the Build System of the plan

Nosotros normally talk about "compiling the sources", but the compilation is only one of the phases required to produce a working software from its source. A build system is a set of tool and practices used to automate and articulate those different tasks in order to build entirely the software just by issuing few commands.

If the concept is elementary, the reality is somewhat more complicated. Because different projects or programming linguistic communication may take unlike requirements. Or considering of the programmer's tastes. Or the supported platforms. Or for historical reason. Or… or.. in that location is an well-nigh endless listing of reasons to choose or create another build system. All that to say there are many dissimilar solutions used out there.

NodeJS uses a GNU-manner build system, information technology is a popular choice in the open source community and once again, a good fashion to commencement your journey.

Writing and tuning a build system is a pretty complex task, merely for the "finish user", GNU-style build systems ease the task past using ii tools: configure and make.

The configure file is a project-specific script that will bank check the destination arrangement configuration and available feature in order to ensure the project can be built, somewhen dealing with the specificities of the electric current platform.

An of import part of a typical configure job is to build the Makefile. That is the file containing the instructions required to effectively build the project.

The make tool, on the other hand, is a POSIX tool available on whatever Unix-similar organisation. It volition read the project-specific Makefile and perform the required operations to build and install your plan.

Merely, as ever in the Linux globe, you lot notwithstanding have some leniency in customising the build to your specific needs.

            ./configure --help          

The configure -assistance command will show you all the bachelor configuration options. Once once more, this is very projection-specific. And to be honest, it is sometimes necessary to dig into the project earlier fully agreement the meaning of each and every configure pick.

Only there is at least 1 standard GNU Autotools option that yous must know: the --prefix option. This has to do with the file system hierarchy and the place your software volition be installed.

[irp posts="14419″ name="8 Vim Tips And Tricks That Will Make Yous A Pro User"]

Step 3: The FHS

The Linux file system hierarchy on a typical distribution by and large comply with the Filesystem Hierarchy Standard (FHS)

That standard explains the purpose of the various directories of your organization: /usr, /tmp, /var and and then on.

When using the GNU Autotools— and most other build systems— the default installation location for your new software volition be /usr/local. Which is a good choice as according to the FSH "The /usr/local bureaucracy is for use by the system administrator when installing software locally? Information technology needs to exist safe from being overwritten when the arrangement software is updated. Information technology may exist used for programs and data that are shareable amid a group of hosts, but non institute in /usr."

The /usr/local hierarchy somehow replicates the root directory, and you will find in that location /usr/local/bin for the executable programs, /usr/local/lib for the libraries, /usr/local/share for architecture independent files and then on.

The only outcome when using the /usr/local tree for custom software installation is the files for all your software volition be mixed there. Peculiarly, afterwards having installed a couple of software, it volition be difficult to rails to which file exactly of /usr/local/bin and /usr/local/lib belongs to which software. That will not cause any issue to the system though. After all, /usr/bin is just almost the aforementioned mess. Simply that will become an outcome the day yous will want to remove a manually installed software.

To solve that consequence, I usually prefer installing custom software in the /opt sub-tree instead. Once again, to quote the FHS:

_"/opt is reserved for the installation of add together-on application software packages.

A package to be installed in /opt must locate its static files in a carve up /opt/<packet> or /opt/<provider> directory tree, where <package> is a name that describes the software package and <provider> is the provider's LANANA registered name."_

So we will create a sub-directory of /opt specifically for our custom NodeJS installation. And if someday I want to remove that software, I will but have to remove that directory:

            sh$ sudo mkdir /opt/node-v8.i.ane sh$ sudo ln -sT node-v8.one.1 /opt/node # What is the purpose of the symbolic link above? # Read the commodity till the end--then try to answer that # question in the comment section!  sh$ ./configure --prefix=/opt/node-v8.1.1 sh$ make -j9 && echo ok # -j9 means run up to 9 parallel tasks to build the software. # As a dominion of thumb, utilise -j(N+i) where N is the number of cores # of your arrangement. That will maximize the CPU usage (one task per # CPU thread/core + a provision of one extra job when a process # is blocked by an I/O operation.          

Anything but "ok" after the make command has completed would hateful there was an error during the build process. As we ran a parallel build considering of the -j option, it is non always easy to retrieve the error message given the large volume of output produced by the build system.

In the example of an issue, just restart brand, only without the -j option this time. And the error should appear virtually the cease of the output:

            sh$ make          

Finally, one time the compilation has gone to the cease, you can install your software to its location by running the command:

            sh$ sudo make install          

And exam it:

            sh$ /opt/node/bin/node --version v8.1.one          

B. What if things go incorrect while installing from source code?

What I've explained above is more often than not what y'all can see on the "build instruction" page of a well-documented project. Just given this article goal is to permit you compile your commencement software from sources, it might worth taking the time to investigate some mutual problems. So, I will do the whole procedure again, only this time from a fresh and minimal Debian 9.0 and CentOS 7.0 systems so you lot can run across the errors I encountered and how I solved them.

From Debian ix.0 "Stretch"

            [email protected]:~$ git clone --depth 1 \                              --co-operative v8.1.1 \                              https://github.com/nodejs/node -fustigate: git: command non found          

This problem is quite like shooting fish in a barrel to diagnosis and solve. Just install the git packet:

            [e-mail protected]:~$ sudo apt-get install git          
            [e-mail protected]:~$ git clone --depth 1 \                              --branch v8.one.1 \                              https://github.com/nodejs/node && repeat ok [...] ok          
            [email protected]:~/node$ sudo mkdir /opt/node-v8.i.1 [email protected]:~/node$ sudo ln -sT node-v8.ane.ane /opt/node          

No problem hither.

            [email protected]:~/node$ ./configure --prefix=/opt/node-v8.i.1/ WARNING: failed to autodetect C++ compiler version (CXX=g++) WARNING: failed to autodetect C compiler version (CC=gcc) Node.js configure mistake: No adequate C compiler found!         Delight make sure you lot have a C compiler installed on your system and/or         consider adjusting the CC environment variable if you installed         it in a non-standard prefix.          

Obviously, to compile a project, you need a compiler. NodeJS being written using the C++ language, we need a C++ compiler. Here I volition install `g++`, the GNU C++ compiler for that purpose:

            [email protected]:~/node$ sudo apt-become install g++ [electronic mail protected]:~/node$ ./configure --prefix=/opt/node-v8.ane.one/ && echo ok [...] ok          
            [email protected]:~/node$ make -j9 && echo ok -bash: make: command non found          

I other missing tool. Same symptoms. Aforementioned solution:

            [email protected]:~/node$ sudo apt-get install brand [email protected]:~/node$ make -j9 && repeat ok [...] ok          
            [email protected]:~/node$ sudo make install [...] [email protected]:~/node$ /opt/node/bin/node --version v8.1.1          

Success!

Delight find: I've installed the various tools ane past i to show how to diagnosis the compilation issues and to show you lot the typical solution to solve those bug. Just if you search for more than data most the topic or read other tutorials, you will discover that most distributions have "meta-packages" interim as an umbrella to install some or all the typical tools used for compiling a software. On Debian-based systems, you lot will probably encounter the build-essentials package for that purpose. And on Red-Chapeau-based distributions, that will be the "Evolution Tools" group.

From CentOS 7.0

            [[e-mail protected] ~]$ git clone --depth 1 \                                --branch v8.1.ane \                                https://github.com/nodejs/node -bash: git: command not institute          

Command not constitute? Just install it using the yum bundle manager:

            [[email protected] ~]$ sudo yum install git          
            [[electronic mail protected] ~]$ git clone --depth 1 \                                --co-operative v8.1.1 \                                https://github.com/nodejs/node && echo ok [...] ok          
            [[email protected] ~]$ sudo mkdir /opt/node-v8.ane.one [[e-mail protected] ~]$ sudo ln -sT node-v8.1.1 /opt/node          
            [[email protected] ~]$ cd node [[email protected] node]$ ./configure --prefix=/opt/node-v8.1.1/ Alert: failed to autodetect C++ compiler version (CXX=g++) Warning: failed to autodetect C compiler version (CC=gcc) Node.js configure error: No acceptable C compiler found!          Please make sure you have a C compiler installed on your system and/or         consider adjusting the CC environment variable if yous installed         information technology in a non-standard prefix.          

Y'all judge it: NodeJS is written using the C++ linguistic communication, but my organisation lacks the corresponding compiler. Yum to the rescue. As I'm non a regular CentOS user, I really had to search on the Internet the exact name of the bundle containing the g++ compiler. Leading me to that page: https://superuser.com/questions/590808/yum-install-gcc-thousand-doesnt-work-anymore-in-centos-6-4

            [[e-mail protected] node]$ sudo yum install gcc-c++ [[email protected] node]$ ./configure --prefix=/opt/node-v8.1.one/ && echo ok [...] ok          
            [[e-mail protected] node]$ make -j9 && echo ok [...] ok          
            [[e-mail protected] node]$ sudo make install && echo ok [...] ok          
            [[email protected] node]$ /opt/node/bin/node --version v8.1.one          

Success. Again.

C. Making changes to the software installed from source code

Yous may install software from the source because youneed a very specific version not available in your distribution repository, or because you lot want to modify the program to fix a bug or add a characteristic. After all, open up-source is all about making modifications. So, I will take this opportunity to give you a gustation of the power you have at hand now that y'all are able to compile your ain software.

Here, we will brand a minor alter to the sources of NodeJS. And we will see if our modify volition be incorporated into the compiled version of the software:

Open the file node/src/node.cc in your favorite text editor (vim, nano, gedit, … ). And try to locate that fragment of lawmaking:

                          if (debug_options.ParseOption(argv[0], arg)) {       // Washed, consumed by DebugOptions::ParseOption().     } else if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) {       printf("%s\n", NODE_VERSION);       exit(0);     } else if (strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0) {       PrintHelp();       go out(0);     }          

It is around line 3830 of the file. And then change the line containing printf to match that one instead:

                          printf("%due south (compiled by myself)\north", NODE_VERSION);          

Then head back to your terminal. Before going further— and to give you some more insight of the ability behind git— you can check if you've modified the right file:

            diff --git a/src/node.cc b/src/node.cc alphabetize bbce1022..a5618b57 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3828,7 +3828,7 @@ static void ParseArgs(int* argc,      if (debug_options.ParseOption(argv[0], arg)) {        // Washed, consumed by DebugOptions::ParseOption().      } else if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) { -      printf("%s\n", NODE_VERSION); +      printf("%s (compiled by myself)\n", NODE_VERSION);        leave(0);      } else if (strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0) {        PrintHelp();          

You should see a "-" (minus sign) before the line as it was before you changed it. And a "+" (plus sign) before the line after your changes.

It is at present time to recompile and re-install your software:

            make -j9 && sudo make install && echo ok [...] ok          

This times, the only reason it might fail is that you've made a typo while changing the code. If this is the case, re-open the node/src/node.cc file in your text editor and prepare the mistake.

Once you've managed to compile and install that new modified NodeJS version, you will be able to check if your modifications were actually incorporated into the software:

            [electronic mail protected]:~/node$ /opt/node/bin/node --version v8.1.1 (compiled by myself)          

Congratulations! You've made your beginning change to an open-source program!

D. Let the beat out locate our custom build software

Yous may have noticed that I've always launched my newly compiled NodeJS software by specifying the absolute path to the binary file.

            /opt/node/bin/node          

Information technology works. But this is annoying, to say the to the lowest degree. There are actually ii common means of fixing that.

There are actually two common ways of fixing the annoying problem of specifying the absolute path to the binary files,
but to understand them yous must first know that your shell locates the executable files by looking for them only in the directories specified past the PATH environment variable.

            [electronic mail protected]:~/node$ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games          

Here, on that Debian organisation, if you lot practise not specify explicitly any directory equally office of a command name, the shell will commencement look for the executable programs in /usr/local/bin, and so if not found into /usr/bin, and so if non plant into /bin then if non institute into /usr/local/games then if not plant into /usr/games, then if not found … the shell will study an error "command not found".

Given that, we have two manner to make a command attainable to the shell: by adding it to one of the already configured PATH directories. Or past adding the directory containing our executable file to the PATH.

Only copying the node binary executable from /opt/node/bin to /usr/local/bin would be a bad idea since by doing so, the executable program would no longer be able to locate the other required components belonging to /opt/node/ (it's a mutual practice for software to locate its resource files relative to its ain location).

And so, the traditional way of doing that is by using a symbolic link:

            [email protected]:~/node$ sudo ln -sT /opt/node/bin/node /usr/local/bin/node [email protected]:~/node$ which -a node || echo not institute /usr/local/bin/node [email protected]:~/node$ node --version v8.1.one (compiled past myself)          

This is a simple and effective solution, peculiarly if a software parcel is made of just few well known executable programs— since you accept to create a symbolic link for each and every user-invokable command. For case, if you lot're familiar with NodeJS, you know the npm companion application I should symlink from /usr/local/bin too. But I let that to you as an practise.

Modifying the PATH

Beginning, if you tried the preceding solution, remove the node symbolic link created previously to commencement from a clear country:

            [electronic mail protected]:~/node$ sudo rm /usr/local/bin/node [email protected]:~/node$ which -a node || echo not plant not found          

And now, hither is the magic command to change your PATH:

            [e-mail protected]:~/node$ consign PATH="/opt/node/bin:${PATH}" [electronic mail protected]:~/node$ echo $PATH /opt/node/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games          

But said, I replaced the content of the PATH environment variable by its previous content, but prefixed by /opt/node/bin. So, as y'all can imagine it at present, the shell will look first into the /opt/node/bin directory for executable programs. We can confirm that using the which command:

            [email protected]:~/node$ which -a node || echo non constitute /opt/node/bin/node [e-mail protected]:~/node$ node --version v8.1.ane (compiled by myself)          

Whereas the "link" solution is permanent every bit soon as you've created the symbolic link into /usr/local/bin, the PATH change is effective only into the electric current shell. I will leave you to do some research on how to make changes in the PATH permanents. As a hint, information technology has to exercise with your "profile". If y'all discover the solution, don't hesitate to share that with the other readers by using the comment department below!

E. How to remove that newly installed software from source code

Since our custom compiled NodeJS software sits completely in the /opt/node-v8.i.i directory, removing that software requires no more endeavor than using the rm command to remove that directory:

            sudo rm -rf /opt/node-v8.1.1          

BEWARE: sudo and rm -rf are a unsafe cocktail! E'er check your control twice earlier pressing the "enter" key. You lot won't have whatsoever confirmation message and no undelete if y'all remove the wrong directory…

So, if you've modified your PATH, you will have to revert those changes, which is non complicated at all.

And if you've created links from /usr/local/bin you lot will have to remove them all:

            [email protected]:~/node$ sudo find /usr/local/bin \                                  -type l \                                  -ilname "/opt/node/*" \                                  -print -delete /usr/local/bin/node          

Look? Where was the Dependency Hell?

As a final comment, if you lot read near compiling your own custom software, you might have heard about the dependency hell. This is a nickname for that annoying state of affairs where before being able to successfully compile a software, yous must first compile a pre-requisite library, which in its plow requires another library that might in its turn be incompatible with some other software you've already installed.

Part of the job of the bundle maintainers of your distribution is to actually resolve that dependency hell and to ensure the various software of your system are using compatible libraries and are installed in the correct lodge.

For this article, I chose, on purpose, to install NodeJS as it virtually doesn't have dependencies. I said "virtually" because, in fact, it has dependencies. Simply the source lawmaking of those dependencies are present in the source repository of the project (in the node/deps subdirectory), so you lot don't take to download and install them manually before hand.

Merely if you're interested in understanding more almost that trouble and learn how to deal with information technology, let me know that using the comment department below: that would be a corking topic for a more advanced article!


Source: https://itsfoss.com/install-software-from-source-code/

Posted by: brownpospits1945.blogspot.com

0 Response to "How To Install At&t U Verse Router"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel