I started to learn about Mix IDE and the thing is that, while compiling the Mix IDE, it keeps failing to compile source in the package. So I've done some search and it turns out that I need to use old version llvm. So I installed llvm37 using home-brew and there was no problem while installing it. The only problem is that when I type
clang --version
it keeps returning the following result.
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Therefore, I need to know how to disable the default LLVM and use the one I installed with Homebrew. Any idea?
You have several options:
Modifying PATH
Put Homebrew's binary path before everything else:
export PATH=/usr/local/bin:$PATH
Uninstalling Xcode command line tools
This will remove the command line tools that are delivered along Xcode.
sudo /Developer/Library/uninstall-devtools --mode=all
If you installed the command line tools without Xcode, see this question. Please be aware that Homebrew might depend on some of those tools and may cease to function! I did not test it.
Setting the desired compiler
This is the cleanest solution. Tell the Mix IDE's build system which compiler to use. Since I do not know which build system Mix IDE uses, I cannot tell you how to do that. Some build systems honor the CC, CXX and CPP environment variables, so it may work setting those to the clang binary installed with Homebrew.
Related
I just started getting into LLVM and clang compilers and the whole thing. I am following the book "Getting started with llvm core libraries". I was under the impression that OS X comes bundled with llvm. However it seems that is not the case. I need to install llvm separately to get command line tools like llc or lli.
So my question is, when I do a "clang" to compile my c/c++ code, what backend does the work of creating the machine code ? My installation shows commands like llvm-gcc and llvm-g++ . Does it mean that it uses gcc internally for creating machine code? And do i need to brew install llvm to switch completely to llvm ?
If you just want clang, and plan to do mostly high-level language development (C, C++, ObjC), then I recommend installing the Xcode command line tools. You can get those from https://developer.apple.com/downloads/index.action?name=for%20Xcode (or you can install all of Xcode if you prefer).
If you want lower-level tools like llc, then my recommendation is brew, as you suggest.
If you're goal is just Mac development, then Xcode is the better solution. If your goal is working on LLVM, then brew is the better answer (or pull the sources and build it yourself).
If you want both on the same machine, I'd recommend not installing the command line tools. Just install Xcode and LLVM. Then you can run the Xcode versions using xcrun without colliding with your LLVM installation.
clang doesn't use llvm-gcc as a backend. It includes LLVM. llvm-gcc is a modified version of GCC that integrates with the LLVM backend, which allows programs that expect GCC-specific features to work with LLVM.
I am trying to uninstall gcc completely from my mac but unable to do so.
Current status :
➜ ~ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin14.0.0 /5.0.0/lto-wrapper
Target: x86_64-apple-darwin14.0.0
Configured with: ../gcc-5-20141005/configure --enable languages=c++,fortran
Thread model: posix
gcc version 5.0.0 20141005 (experimental) (GCC)
~ which gcc
/usr/local/bin/gcc
I had xcode installed and I removed that completely and also I tried to uninstall using brew. I think I had two different versions installed one using brew and other directly from hpc.sourceforge.net .
Since you have your gcc in /usr/local, it is not part of your operating system. The cleanest - but brute force - way is to delete /usr/local completely, and then reinstall the things you want to have there. See also here.
/usr/local is a directory that doesn't come from OSX, but is used by tools like Homebrew. If you delete it, you will lose everything you installed with Homebrew, including Homebrew itself, but you can reinstall it afterwards. You will also lose other tools that install themselves in there. Depending on how much you have there, it may be a quick or a very long procedure.
If you don't want to do this, you have to consult the source that provided you with your gcc. Or you could just rm gcc and its related binaries under /usr/local/bin and everything under /usr/local/libexec/gcc. This will not harm your OS, but it will probably leave you behind with unnecessary files littering your /usr/local. I strongly advice against doing this unless you know what you're doing.
So I just installed Xcode on my Mac and now I would like to install LLVM as well in order to play around a bit with LLVM itself. Currently the compiler can (obviously) not find the required header files. So what is the best way to install LLVM if you already have clang, packed with Xcode, on your system?
Thanks in advance.
If you do not need to read LLVM implementation source code(such as in lib/tools directories) and might only play with libclang, perhaps using homebrew is enough for you.
brew install --with-clang --with-lld --with-python --HEAD llvm
Next you need to set PATH, CPLUS_INCLUDE_PATH and LD_LIBRARY_PATH. For me,
# export PATH=/usr/local/opt/llvm/bin:$PATH
# export CPLUS_INCLUDE_PATH=$(llvm-config --includedir):$CPLUS_INCLUDE_PATH
# export LD_LIBRARY_PATH=$(llvm-config --libdir):$LD_LIBRARY_PATH
You might configure the above information in your LLVM derived project with XCode.
However if you are also interested in Compiler-RT, Clang-Tools-Extra(see LLVM Download Page) you probably have to make LLVM as your XCode project (download from that page or via SVN as said in Getting Started with the LLVM System). After putting the sub-projects in proper directories, you can use XCode generator from CMake, the typical usage is:
cd YOUR_LLVM_SRC_ROOT
mkdir build
cd build
cmake -G Xcode ..
Use XCode to open the project file XXX.xcodeproj and it should build the project.
I tried brew install --with-clang --with-lld --with-python --HEAD llvm as suggested in the other answer, but it gave me an error:
Error: invalid option: --with-clang
brew options llvm also showed nothing.
Then I found another page that suggests the simple
brew install llvm
This worked for me. It is with homebrew 2.4.0, on MacOS Mojave.
If you need to have llvm first in your PATH run (replace <your_username> with your username):
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> /Users/<your_username>/.bash_profile
For compilers to find llvm you may need to set:
export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include"
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.
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