thoughtbot/capybara-webkit — Issue #291: OSX 10.7 - XCode/Brew GCC problems
Author: dcunited001
Created: 2012-03-10 03:37:57+00:00
State: open

So i just installed Lion and I've worked through a lot issues stemming from XCode's lack of GCC 4.2

So I installed apple-gcc42 from homebrew using `brew install apple-gcc42`. This has fixed most of my issues but i ran into problems installing capybara-webkit.

Makefile.webkit_server includes the following lines:

CFLAGS = -pipe -O2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W $(DEFINES)
CXXFLAGS = -pipe -O2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W $(DEFINES)

I try to bundle install and i get the following error:

================================================================

Installing capybara-webkit (0.10.1) with native extensions Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issues so that we can fix it. Thanks!
/Users/davidconner/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:552:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/Users/davidconner/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
cd src/ && /usr/local/bin/qmake /Users/davidconner/.rvm/gems/ruby-1.9.3-p125@arix/gems/capybara-webkit-0.10.1/src/webkit_server.pro -spec /usr/local/Cellar/qt/4.8.0/mkspecs/macx-g++ -o Makefile.webkit_server
cd src/ && make -f Makefile.webkit_server
g++ -c -pipe -O2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_NO_DEBUG -DQT_WEBKIT_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Cellar/qt/4.8.0/mkspecs/macx-g++ -I. -I/usr/local/Cellar/qt/4.8.0/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.0/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.0/lib/QtNetwork.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.0/lib/QtNetwork.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.0/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.0/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.0/lib/QtWebKit.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.0/lib/QtWebKit.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.0/include -I. -F/usr/local/Cellar/qt/4.8.0/lib -o CurrentUrl.o CurrentUrl.cpp
g++: unrecognized option '-Xarch_x86_64'
cc1plus: error: unrecognized command line option "-arch"
make[1]: *** [CurrentUrl.o] Error 1
make: *** [sub-src-webkit_server-pro-make_default-ordered] Error 2

make
cd src/ && make -f Makefile.webkit_server
g++ -c -pipe -O2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_NO_DEBUG -DQT_WEBKIT_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Cellar/qt/4.8.0/mkspecs/macx-g++ -I. -I/usr/local/Cellar/qt/4.8.0/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.0/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.0/lib/QtNetwork.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.0/lib/QtNetwork.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.0/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.0/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.0/lib/QtWebKit.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.0/lib/QtWebKit.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.0/include -I. -F/usr/local/Cellar/qt/4.8.0/lib -o CurrentUrl.o CurrentUrl.cpp
g++: unrecognized option '-Xarch_x86_64'
cc1plus: error: unrecognized command line option "-arch"
make[1]: *** [CurrentUrl.o] Error 1
make: *** [sub-src-webkit_server-pro-make_default-ordered] Error 2

================================================================

The flag -arch is apple specific and only works with apple's wrapper for gcc. I changed these lines to the following:

CFLAGS = -pipe -O2 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W $(DEFINES)
CXXFLAGS = -pipe -O2 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W $(DEFINES)

And then i added the following options to my gemfile:

gem 'capybara-webkit', :path => '/Users/davidconner/.rvm/gems/ruby-1.9.3-p125@arix/gems/capybara-webkit-0.10.1'

when i ran bundle install, everything installed properly this time.