How do I install GCC and make on a Mac without administrator access or using Xcode?

1k views Asked by At

I'd like to install gcc and make on my Macbook Air, but I don't have root access on it. I found this link through searching on google, but I have no idea how to set up the prefix's so that the actual gcc executable can find the libraries. I have a directory set up with node.js and git installed at ~/usr/local and I'd like to install GCC there also. I have no idea where to start with make. Can anyone help? :D

2

There are 2 answers

1
andrewdotn On BEST ANSWER

I tried this on Mountain Lion. Let me know if you have any problems or can’t get something similar working on Mavericks. I remember what a huge pain it was to learn to use computers back when I didn’t have my own and couldn’t install software on the ones at school.

This procedure will get you up and running with make and a basic C compiler.

First, download the “Command Line Tools (OS X Mountain Lion) for Xcode - October 2013” package from https://developer.apple.com/downloads. You need to register and sign in with an Apple ID, but you don’t need to pay anything.

Then, after you open the DMG, unpack the files inside it into your home directory and add the tools to your $PATH:

$ mkdir -p ~/tmp ~/opt/devtools
$ cd ~/tmp
$ tar xf '/Volumes/Command Line Tools (Mountain Lion)/Packages/DeveloperToolsCLI.pkg'
$ tar xf Payload
$ tar xf '/Volumes/Command Line Tools (Mountain Lion)/Packages/DevSDK.pkg'
$ tar xf Payload
# Ignore the error messages!
$ mv usr System Library ~/opt/devtools
$ echo 'export PATH="${PATH}:${HOME}/opt/devtools/usr/bin"' >> ~/.bash_profile

Now open a new Terminal and try it out!

$ echo '#include <stdio.h>

int main() {
  printf("Hello, world!\n");
  return 0;
}' > foo.c
$ CFLAGS=-I"${HOME}/opt/devtools/usr/include" make foo
cc -I/Users/test/opt/devtools/usr/include    foo.c   -o foo
$ ./foo
Hello, world!

All basic C stuff should work. Some Apple-specific stuff might require fiddling around with search paths or might not work at all, but now you’re on your way.

Good luck!

0
Milliways On

If you don't have Administrator access you need to get the person who does to install programs.