Using 'make' on OS X - macos

I have a MacBook Pro that I'm trying to do some development on.
I have a program I want to build, and when I went to use make to build it, I got a "command not found" error. I did some googling and Stack Overflow searches and it doesn't look like this is a common problem. Why don't I have make installed and how do I get it?
I'm extra confused, because I know I used it relatively recently (in the past month or so) when I was on this laptop.

For those of you who get to this page using Xcode 4.3 and Lion, the command line tools are no longer bundled by default, and there is no /Developer anymore. To install them, open Xcode, go to Preferences -> Downloads -> Components -> Command Line Tools. This should install make, gcc etc.

Have you installed the Apple developer tools?
What happens if you type gcc -v ?
It look as if you do not have downloaded the development stuff. You can get it for free (after registration) from http://developer.apple.com/

There is now another way to install the gcc toolchain on OS X through the osx-gcc-installer this includes:
GCC
LLVM
Clang
Developer CLI Tools (purge, make, etc)
DevSDK (headers, etc)
The download is 282MB vs 3GB for Xcode.

You will have to install the "Developer Tools" that are provided as optional packages in OS X installation disks.

For Xcode 4.1 you can simply add /Developer/usr/bin to the PATH environment variable. This is easily done:
$ export PATH=$PATH:/Developer/usr/bin
Also be certain to update your ~/.bashrc (or ~/.profile or ~/.bash_login) file.

In addition, if you have migrated your user files and applications from one mac to another, you need to install Apple Developer Tools all over again. The migration assistant does not account for the developer tools installation.

If you've installed Xcode 4.3 and its Command Line Tools, just open Terminal and type the following: On Xcode 4.3, type the following in Terminal:
export PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin

#Daniel's suggestion worked perfectly for me. To install make, open Xcode, go to Preferences -> Downloads -> Components -> Command Line Tools.You can then test with gcc -v

I agree with the other two answers: install the Apple Developer Tools.
But it is also worth noting that OS X ships with ant and rake.

I believe you can also get just the Xcode command-line tools which is about 170 MB.. It's described in the 'brew' setup guide: https://github.com/mxcl/homebrew/wiki/installation and can be found here: https://developer.apple.com/downloads/index.action#
Edit: this was already mentioned above by #josh

I found the Developer Tools not as readily available as others. In El Capitan, in terminal I just used gcc -v, it then said gcc wasn't available and asked if I wanted to install the command line Apple Developer Tools. No downloading of Xcode required. Terminal session below:
Pauls-MBP:~ paulhillman$ gcc -v
xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.
Pauls-MBP:~ paulhillman$ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Related

How to downgrade command line tools MacOS

I got a dynamic linker error with the __clock_gettime symbol so I did what this post said Missing symbol when installing ruby-2.3.0 on OS X 10.11.6 by RVM (i.e. xcode-select --install) and now I am getting loader errors that say that libraries were built for a newer OS version than the one I am currently running on, I dont want to upgrade my OS to the newer (Sierra) version though, is there a way you can downgrade the command line tools to an older version (10.11?)
It's unclear which version of Xcode you are using, although it is possible to have multiple versions of the command-line tools installed, which can be selected in Xcode Preferences.
Command Line tools come with Xcode. If you delete and downgrade Xcode it should do the trick. Once you delete Xcode from you applications, use "Previous versions of Xcode can also be downloaded here" link in https://developer.apple.com/support/xcode/.
SPOILER ALERT: You need to have/create an apple dev account for this
Can download command line tools without the complete Xcode application here: https://developer.apple.com/download/all/?q=command%20line%20tools

Xcode Command-Line Tools & Make

I have installed Xcode 5 on OS X Mavericks. I have a problem with the command-line tools (cc et al).
The version of cc in /usr/bin is outdated, so I’m not using it. The version of cc embedded deep within Xcode’s application bundle is current, so I’ve pasted the following code into my shell profile:
export PATH=`xcode-select -print-path`/usr/bin:`xcode-select -print-path`/Toolchains/XcodeDefault.xctoolchain/usr/bin:${PATH}
This worked under Xcode 4 on Mountain Lion. Now, however, while the compiler seems to run fine when invoked as cc, it won’t compile anything when I invoke it that way; it apparently cannot find system headers (e.g. stdio.h). When I invoke the compiler as xcrun cc, everything works just fine. Unfortunately, this requires me to patch the inputs for each and every build-automation program (such as make) before they will run properly.
The other problem is that I cannot find the command-line tools for download from ADC. As I upgraded from Mountain Lion, invoking /usr/bin/cc does not ask me if I want to download the tools; it just runs the (outdated) copy of cc from Xcode 4.
What is the difference between cc and xcrun cc, and is there anything I can do that will cause cc to work properly from the Terminal (or automated build tools)?
On OS X 10.9 Mavericks, run xcode-select --install to update the installed command line tools so they match the version inside of Xcode. This also installs header files into /usr/include and /System/Library and installs additional development libraries. This is a change from previous versions of OS X where the command line tools were either installed via Xcode.app itself or by an Xcode installer. It is still possible to download a standalone installer from the Apple Developer site but should normally no longer be necessary on 10.9.
I have no problems with cc (although you will get better results if you use clang instead of cc. I suggest that you remove the program, download it again, and install the command line tools with xcode-select --install

How to use g++ in terminal in mac?

I've installed Xcode and I can compile .cpp files in Xcode. However, I wanna use g++ in Terminal but command not found: g++ now.
My OS is Mountain Lion Xcode version is 4.4.
You need to download and install the Command Line Tools for OSX Mountain Lion from Apple Developer (you'll need a Apple ID which is free to sign up for). This will install GCC (including g++) so you can build direct from Terminal
The exact package currently is Command Line Tools (OS X Mountain Lion) for Xcode - September 2012
Description about the package from Apple:
This package enables UNIX-style development via Terminal by installing command line developer tools, as well as Mac OS X SDK frameworks and headers. Many useful tools are included, such as the Apple LLVM compiler, linker, and Make. If you use Xcode, these tools are also embedded within the Xcode IDE, and can be installed on your system using the Downloads preferences pane within Xcode 4.5.
Note that when you run "g++" with Xcode 4.5 installed, you're picking up llvm-g++-4.2 (based on gcc 4.2.1) -- a provided, but no longer supported compiler on the platform. I'd strongly recommend using clang++ instead, the actively supported/developed compiler on the platform.

Setting environment variables to compile node on Mountain Lion with XCode4.4

After upgrading to Mountain Lion (10.8) and XCode 4.4, and installing the XCode Command Line utilities from the XCode Preferences pane, I was unable to compile node.js (0.8.5) from source. Specifically, the configure script believed that I did not have a C compiler installed.
It looks to me like the environment variables required for the command line tools were lost somewhere along the way.
I tried sudo xcode-select --switch /Applications/Xcode.app but this did not appear to clear up the problem.
I had to perform these steps to make the node build system happy:
export PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin
export CC='gcc --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/'
export CXX='g++ --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/'
After that I was able to compile and link.
So... why did I have to do this? Am I missing some easy step that could have done this for me automatically? Or am I in some bad state because I installed XCode before upgrading to Mountain Lion, and the XCode updater went off the rails?
Once you've updated to Mountain Lion and updated XCode 4.4, you have to reinstall the command line tools inside XCode.
Go to XCode/Preferences/Downloads/Components and click install on "Command Line Tools" and once it has downloaded and installed, you should once again have gcc and g++ in your (normal) path.
The correct thing to do was to reinstall the command-line tools from inside Xcode.
This was temporarily impossible because a malformed download list was being served by Apple, but the problem was fixed. The malformation was detectable by inspecting the output from Xcode in Console.
Once the tools were reinstalled, compilation worked normally.
http://docwiki.embarcadero.com/RADStudio/XE4/en/Installing_the_Xcode_Command_Line_Tools_on_a_Mac
Please refer the above link and try to install command line from apple developer portals

Can't use GCC in OS X Terminal

I have installed the developer tools. I can compile code via Xcode and according to the docs /usr/bin/gcc & /usr/bin/cc should point to /usr/bin/gcc-4.0. Neither the symlinks or gcc-4.0 exist on my system (Snow Leopard). All I wish to do is compile some C on the terminal! I'm amazed by how complicated this task is. The command GCC is unsurprisingly returning "gcc: command not found".
Can anyone shed some light on this?
No! Reinstalling is the wrong answer!
Newer versions of XCode require you to install the command-line versions of the tools separately. In XCode, go to Preferences | Downloads, check the Components tab, and install them from there:
These binaries should be there after installing xcode. Check your path settings, and if you still don't have these reinstall xcode
Command line tools are no longer included with the latest XCode (even as an add on). Now you can download them here:
https://developer.apple.com/downloads/index.action
Did you install the latest Xcode after installing Snow Leopard, or is this the version of Xcode from a previous OS installation?
On my system with a clean Snow Leopard install the default compiler (and the one symlinked from cc and gcc) is gcc-4.2
I do have gcc-4.0 too, although it's not the default.

Resources