Reputation: 23
I am trying to use Clang.
First, I downloaded the first two source files (LLVM source code + Clang source code) from here, under section "download llvm 3.8.1".
Then, I extracted them, and renamed the obtained extracted directories to llvm and clang (respectively). Then, I put the clang directory inside llvm/tools.
Finally, I followed the instuctions here, under the section "building Clang and working with the code", in the subsection "on Unix-like systems".
BTW, the reason why I renamed the directories to clang and llvm as in these insturctions these are the names of the directories, so I guess I should rename them.
And in step 9 ("try it out"), when I typed "clang --help", I got the message:
"The program 'clang' can be found in the following packages:
Try sudo apt-get install < selected package >"
This means that the installation failed. Why? What else should I do?
Thanks in advance!
Upvotes: 2
Views: 7810
Reputation: 101
The newly built clang
will be in the bin
directory of the build directory and this build directory is the location where you executed the command:
$ cmake -G "Unix Makefiles" <path_to_the_sources>
To run this clang, you will need to add the path to it:
$ <path_to>/bin/clang
Or you can -- as the instructions you referred to suggest -- add the full path to the clang to your PATH variable.
If your current directory is where clang
is located, then you still need to add the current directory to it by using ./
:
$ ./clang
This is not specific to clang by the way. If you type the name of any executable without a path:
$ <name_of_executable>
then the command-line interpreter will look for that executable in all the directories in the $PATH variable.
You can look at the list of these directories by entering
$ echo $PATH
And you will see something like
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
The command line interpreter will iterate through the list and will start the executable only if it's found in one of these directories.
(On Windows, the command line interpreter will also look in the current directory; this is why entering the name of the program by itself works if it is located in the current directory)
You can see where a program that can be executed without specifying the path is located by using the which
command:
$ which gcc
/usr/bin/gcc
and to pay our dues to the recursive tradition of Unix:
$ which which
/usr/bin/which
Upvotes: 1