Gcc 4.2 version missing - macos

on my new macbook pro with osx lion and XCode 4.1 I have some problems with gcc.
In /usr/bin I cannot find gcc-4.2
I only have the following versions:
i686-apple-darwin11-llvm-gcc-4.2
llvm-gcc
llvm-gcc-4.2
As a result when I try to select gcc42 by means of port select --set gcc gcc42 it returns me the following error:
Selecting 'gcc42' for 'gcc' failed: could not create new link "/opt/local/bin/gcc": target "/usr/bin/gcc-4.2" doesn't exist
However port select gcc returns me the following versions:
apple-gcc42
gcc42
llvm-gcc42 (active)
mp-gcc44
How can I fix this problem?
Thanks!

I could manage to solve this issue in Mountain Lion with a symbolic link:
sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2
Hope this help someone

There should be a /usr/bin/gcc-4.2 with Xcode 4.1 installed. However, with the recent Xcode 4.2 update, Apple has finally removed their modified standard gcc-4.2. What remains is either llvm-gcc42 (also symlinked to gcc) and clang, the newer non-gcc C compiler. Apple is making the transition to clang; the first step is using the hybrid llvm-gcc42. There have been some reported problems using either of the new compilers. You should be using this time to figure out if you have problems with them and, if so, fix your code and report bugs to Apple. In the meantime, if you absolutely have to have the old gcc-4.2, it is possible to build one similar to the previous Apple-modified one via MacPorts:
port install apple-gcc42
but you'll be swimming against the tide.

With Xcode 4.3, you need to install the Command Line Tools separately. XCode -> Preferences -> Downloads, Click the Components button, and then click Install next to the "Command Line Tools" option.

I had the same issue.
I fixed it by doing a symlink.
Like this :
cd /usr/bin
then :
sudo ln -s llvm-gcc-4.2 gcc-4.2

You might consider compiling a newer GCC (e.g. 4.6.2) from its source code. Apple does not care much any more about GCC, but GCC has made significant progress since 4.2
And you probably could use your llvm-gcc42 as a GCC compiler.

I tampered with the innards of the makefile and found out that one invoked option provided an argument too many; replaced the variable with the actual result of the function called on my machine (removing the excess argument) and did run make again it worked.

Related

Install GCC 5.X on Xcode 6

I need to use/integrate GCC 5.X (in my case 5.3, and it is already installed) on Xcode 6.2.
I've found a lot of outdated tutorials about GCC 4.X and Xcode 5 (or lower), but all of them are outdated and do not work anymore.
I've also found this tutorial, but I have not the 5.3.xcplugin file that the tuto recommend to copy.
I am still on Mac OS X Maverick, and I can install Xcode 7 if necessary.
Anybody would know how to do it?
MacPorts still has an installer for Mavericks. It will likely add /opt/local/bin:/opt/local/sbin to your $PATH in .profile, or whatever shell startup file you use, and leave a backup of the old file you can probably get rid of once you're satisfied.
I would suggest upgrading to the latest Xcode release - and to El Capitan unless you have some specific reason not to. AFAIK, if you can run Mavericks, you can run the latter. I will avoid any arguments about the merits of Brew vs. MacPorts here. There's plenty of documentation on the MacPorts pages.
Make sure the package database is up to date:
sudo port -v selfupdate`
Have a look at the existing gcc ports:
port list | grep gcc
note: you might as well install the stable gcc6 (6.1.0) package.
Install the package - this may also install dependency packages:
sudo port install gcc6 [-universal]
This may take a while, as it might need to build from source. For most packages, the -universal flag says that you don't care about 32-bit (IA32) builds, etc.
You can see various package versions with port select ... options, e.g.,
port select --list gcc
And enable the installed gcc:
sudo port select --set gcc mp-gcc6
You may need to rehash so the shell adds the new binaries to its search. Or just start a new shell. gcc -v should yield something like:
gcc version 6.1.0 (MacPorts gcc6 6.1.0_0)

Installing LLVM libraries along with Xcode

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"

Downgrade or remove GCC 4.8 from Mac OS X Mountain Lion

I am in the process of trying to essentially start from scratch with getting homebrew, GCC and RVM 1.9.3 on to my mac OS x 10.8.2 after determining that my problems with RVM were "related to a messy environment which can not be fixed automatically without what we plan for RVM2" in a thread that began here on SO and ended as a github for ticket RVM.
I had XCode 4.6 with Command Line Tools installed as was recommended here but at this point have completely deleted XCode (by trashing it- due to the version sudo /Developer/Library/uninstall-devtools --mode=all did not work), I uninstalled homebrew by running
cd `brew --prefix`
brew install libtool
rm -rf Cellar
rm `git ls-files`
rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions
rm -rf .git
rm -rf ~/Library/Caches/Homebrew
and imploded my rvm. However, I am not sure how to go about 'refreshing' my GCC situation. Which is as follows:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-apple-darwin12.2.0
Configured with: ../gcc-4.8-20130113/configure --enable-languages=c++,fortran
Thread model: posix
gcc version 4.8.0 20130113 (experimental) (GCC)
I have Time Machine backups from various stages of my undoing and made a bootable USB of Mountain Lion but was hoping to try reinstalling a fresh copy of Xcode or running the GCC-10.7 program installer before using either of those methods. However, I don't know if I can or how I would rectify the GCC situation before doing so.
From reading Change to GCC 4.7.., it seems that there might be a way of pointing/directing my system to a different version of GCC, but I don't know how to do that without MacPorts or homebrew.
Is there a way to get rid of the experimental GCC 4.8 so it doesn't come back in the future?
I have run a VM of my system with a copy of /usr/local/ from before I had ever installed XCode CLT or any of these other libraries, but my $ gcc -v still came back with gcc version 4.8.0
Sorry if I omitted and/or added necessary/unnecessary information and thank you in advance for any help.
This is a confusing dump of information. You don't want to use MacPorts or Homebrew? I seriously recommend you go with Homebrew. That should get the latest GCC 4.8 onto OR OFF OF your box with ease. If you can't figure out where your current gcc 4.8 is, try typing "which gcc" and that will tell you where it's located. It's not coming back. Clearly you never removed it if typing gcc brings up gcc. It's probably in /usr/local/opt.
If you insist on wiping out ALL the homebrew stuff manually, you COULD just zap /usr/local/opt to get rid of the symlinks, and /usr/local/Cellar to get rid of the real stuff, but I don't recommend it. Why? Zapping directories by hand could cause you to lose data especially if you're prone to making mistakes. Use MacPorts or Homebrew to REMOVE whatever you used it to install.

Error building Omnet++: Cannot build Tcl/Tk apps on Mountain lion

I'm trying to Compile Omnet++ 4.1 on Mountain Lion. When I type:
./configure
I get the following error:
configure: error: Cannot build Tcl/Tk apps, probably due to misconfigured or missing X11 headers or libs. Check config.log for more info!
I remember compiling it on Lion without any problems, any ideas how to get it working on Mountain Lion?
Found a solution for this over on the omnetpp google group, I'll paste it in here:
Hi all,
just tried Mountain Lion, which was released yesterday. Unfortunately,
the new MacOSX does not include X11 by default. I really HATE this
decision. As a result, it does not pass the Tcl/Tk checks when we do
./configure.
After hours of efforts, I finally figured out how to work around this:
download and install XQuartz at http://xquartz.macosforge.org/landing/
make a symbolic link at /usr/include: sudo ln -s /opt/X11/include/X11 /usr/include
and you are all set. In 2, you may also set some environment variables
accordingly instead of making the symbolic link.
Future OMNet++ releases may consider setting associated environment
variables so that the compiler looks for Xlib.h in
/opt/X11/include/X11 with Mountain Lion.
Just successfully compiled the simulator and haven't encountered other
problems yet.
Have fun,
TS
If you have the same problem on Linux (ubuntu) a solution is run this in the console:
sudo apt-get install build-essential gcc g++ bison flex perl tcl-dev tk-dev blt libxml2-dev zlib1g-dev openjdk-6-jre doxygen graphviz openmpi-bin libopenmpi-dev libpcap-dev
Installing XQuartz is still the solution to overcome this problem.

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