I am trying my best to have a working compiler on a fresh ubuntu installation, without having access to root privileges on the machine (my user is also not on the sudoers
list).
To me, this is totally non-trivial. I cannot found any portable gcc
for ubuntu (or linux in general) nor any recipe to create it.
Since on a freshly installed ubuntu you don't even have make
, and there's no compiler to build it, at least I found out that I could download the make-x.xx.deb
file with apt-get download make
(it doesn't require sudo
, of course, since it just downloads the deb package), extract it with dpkg -x
(dpkg -i --force-not-sudo
does not work...) and manually point to the extracted binary.
I tried the same with gcc
, downloading also all the packages that apt-get install
would have downloaded. Unsurprisingly, it didn't work. Not even adding to PATH, LD_LIBRARY_PATH, LIBRARY_PATH, COMPILER_PATH many folders did the magic. Fixing one problem after the other, the final insurmountable error with paths tricks was /usr/bin/ld: cannot find /usr/lib/x86_64-linux-gnu/libmvec_nonshared.a
As I expected, the gcc
compiler is hardcoded to look for at least one library in a place I cannot write anything (/usr/lib/...
). Maybe there're also others I don't know about that would fail later.
I tried also to download a prebuilt binary of clang
from the LLVM website. The problem is that the clang compiler, without any gcc
installed, is completely non-functional. I can make it look to the gcc
headers extracted from the .deb files above, but it finally fails because it cannot find a ld
executable on the system for the linking phase (I had to remove the manually extracted gcc
from the path for other problems).
So here I am, asking for suggestions: how to install gcc (or any other decent compiler/build environment) on ubuntu without admin privileges? I cannot think it's not already solved as a problem [to add fuel to the fire, on windows is easy and possible with a couple of downloads from official websites].
The only idea I came up with is to build it on another identical machine on which I have admin privileges, using the --prefix
and the --disable-shared
switches, and find a reasonable place to store the resulting package (after a tar.gz
treatment) online. But the resulting script does not look legit, when you see it is going to download a compiler from an unknown personal website...
./configure --prefix=$HOME && make && make install
? That should do the job; if it doesn't, there's surely a bug. – Jan 18 '18 at 18:22make
was not available. I fixed it somehow extracting from the deb file. But then alsogcc
is not available. How to build gcc without another compiler? That's why I was looking for an official portable compiler, or something to bootstrap the toolchain on a per-user basis. It is possible on other systems, why not on ubuntu/linux?? With this portable compiler (whatever it is, just a sane one), I can then build my own gcc! – Stefano Sinigardi Jan 18 '18 at 18:25gcc
in an unusual place, with many supporting files in other unusual places, and that will make it very hard to use if you want to compile other things here. I would suggest just downloading a base distribution as an archive and using it by doing a chroot in it, or some container/VM tech so that you have a new standard layout of files and enough rights to install in them what you need normaly with the distribution tool. But then it depends on how this locally compiledgcc
will be used. – Patrick Mevzek Jan 21 '18 at 19:21sudo apt install gcc
, but I'd avoid it for my experiment. I realize now that it's becoming too complex to do, but IMHO it's strange that there's no portable gcc for Linux... – Stefano Sinigardi Jan 23 '18 at 10:55gcc
, it is another compiler. But specifically portable. – Patrick Mevzek Jan 26 '18 at 20:54make
beforehand, and how will you compilemake
sources if you do not want to install it either? – Patrick Mevzek Jan 26 '18 at 20:58chroot
to trick tools into some defined hierarchy when instead you are elsewhere. – Patrick Mevzek Jan 26 '18 at 21:25chroot
unfortunately requires root privileges.... – Stefano Sinigardi Jan 26 '18 at 21:28chroot
as in this example: https://askubuntu.com/a/193704 (look at second answer too) and https://github.com/dex4er/fakechroot . Not judging it, but you also have https://github.com/Linuxbrew/brew – Patrick Mevzek Jan 26 '18 at 21:30fakechroot
! https://github.com/dex4er/fakechroot which allows to do (as non root):fakechroot fakeroot debootstrap sid /tmp/sid ; fakechroot fakeroot chroot /tmp/sid apt-get install -q hello ; fakechroot chroot /tmp/sid hello
– Patrick Mevzek Jan 26 '18 at 21:31