Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Clang as User (no Root Privileges)?

I have access to a shell account at University as a user but with no root privileges. The server is running Ubuntu 8.04 - Hardy. I wish to use Clang as my C compiler for next semester's Unix programming course. GCC is installed but not Clang, and the University's IT dept has, as expected, declined to install Clang on the system.

Is it possible to run Clang from my home directory as user? Presumably I would need to compile from source. I need it to compile only C. I don't need C++ or Obj C for this course.

like image 954
haziz Avatar asked Dec 30 '11 16:12

haziz


3 Answers

You can use the autotools installation method by running ./configure --prefix=$HOME (or some subdirectory of your home directory if you prefer) or by using the CMake build and installation with the CMAKE_INSTALL_PREFIX set to some directory under your home. The former is documented here, merely add the --prefix flag to the configure step, and run 'make install' at the end.

Once installed, put the bin subdirectory of whatever prefix you used into your PATH environment variable, and you should be good-to-go. This is actually the way I use Clang regularly as a developer of Clang and LLVM.

For reference, this is definitely a mode of installation and use that we (Clang developers) want to support. If you run into issues, don't hesitate to file bugs or reach out for support on our email lists or IRC channel (#llvm on irc.oftc.net).

like image 147
Chandler Carruth Avatar answered Oct 20 '22 06:10

Chandler Carruth


With free software, you can always configure it and (if needed) patch and improve it to suit your needs. However, building a compiler (be it GCC or Clang) requires a lot of resources (disk space, several gigabytes, and also RAM & CPU time), and some of your time and efforts.

Clang building and installation is documented here. I guess that its configure script -assuming it is similar to GCC's one- accepts arguments like --prefix (which you could e.g. set to $HOME/pub). You might need to build also the required dependencies.

like image 41
Basile Starynkevitch Avatar answered Oct 20 '22 07:10

Basile Starynkevitch


As the project appears to use autotools you can alter the installation destination with command line parameters to the configure program (e.g. --prefix=$HOME/clang). Running ./configure --help and reading the INSTALL text file will give you more details.

If not already installed, you also need to build LLVM, which is the parent project (Low Level Virtual Machine) as well. Installation instructions for both are available at the clang website.

like image 20
mctylr Avatar answered Oct 20 '22 05:10

mctylr