Skip to content

Commit ab839f5

Browse files
committed
support OS X Yosemite / 10.10
- pick libstdc++ for OS X (regardless of version) - make gtest rely on its own tuple to not conflict with clang (thanks @pluskid!) - 10.10 has Accelerate while 10.9 has vecLib for BLAS (thanks @leonardt and @drdan14)
1 parent 25e3748 commit ab839f5

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

Makefile

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,15 @@ endif
234234
# libstdc++ instead of libc++ for CUDA compatibility on 10.9
235235
ifeq ($(OSX), 1)
236236
CXX := /usr/bin/clang++
237+
CXXFLAGS += -stdlib=libstdc++
238+
LINKFLAGS += -stdlib=libstdc++
237239
# clang throws this warning for cuda headers
238240
WARNINGS += -Wno-unneeded-internal-declaration
239-
ifneq ($(findstring 10.9, $(shell sw_vers -productVersion)),)
240-
CXXFLAGS += -stdlib=libstdc++
241-
LINKFLAGS += -stdlib=libstdc++
242-
endif
241+
# gtest needs to use its own tuple to not conflict with clang
242+
CXXFLAGS += -DGTEST_USE_OWN_TR1_TUPLE=1
243243
# boost::thread is called boost_thread-mt to mark multithreading on OS X
244244
LIBRARIES += boost_thread-mt
245-
NVCCFLAGS += -DOSX
245+
NVCCFLAGS += -DOSX
246246
endif
247247

248248
# Custom compiler
@@ -304,9 +304,16 @@ else
304304
endif
305305
else ifeq ($(OSX), 1)
306306
# OS X packages atlas as the vecLib framework
307-
BLAS_INCLUDE ?= /System/Library/Frameworks/vecLib.framework/Versions/Current/Headers/
308307
LIBRARIES += cblas
309-
LDFLAGS += -framework vecLib
308+
# 10.10 has accelerate while 10.9 has veclib
309+
XCODE_CLT_VER := $(shell pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep -o 'version: 6')
310+
ifneq (,$(findstring version: 6,$(XCODE_CLT_VER)))
311+
BLAS_INCLUDE ?= /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/
312+
LDFLAGS += -framework Accelerate
313+
else
314+
BLAS_INCLUDE ?= /System/Library/Frameworks/vecLib.framework/Versions/Current/Headers/
315+
LDFLAGS += -framework vecLib
316+
endif
310317
endif
311318
endif
312319
INCLUDE_DIRS += $(BLAS_INCLUDE)

docs/installation.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Installation
55
# Installation
66

77
Prior to installing, it is best to read through this guide and take note of the details for your platform.
8-
We have installed Caffe on Ubuntu 14.04, Ubuntu 12.04, OS X 10.9, and OS X 10.8.
8+
We have installed Caffe on Ubuntu 14.04, Ubuntu 12.04, OS X 10.10, 10.9, and 10.8.
99

1010
- [Prerequisites](#prerequisites)
1111
- [Compilation](#compilation)
@@ -156,9 +156,9 @@ Building boost from source is needed to link against your local Python (exceptio
156156
**Note** that the HDF5 dependency is provided by Anaconda Python in this case.
157157
If you're not using Anaconda, include `hdf5` in the list above.
158158

159-
#### 10.9-specific Instructions
159+
#### 10.10- and 10.9-specific Instructions
160160

161-
In OS X 10.9, clang++ is the default C++ compiler and uses `libc++` as the standard library.
161+
In OS X 10.9+, clang++ is the default C++ compiler and uses `libc++` as the standard library.
162162
However, NVIDIA CUDA (even version 6.0) currently links only with `libstdc++`.
163163
This makes it necessary to change the compilation settings for each of the dependencies.
164164

@@ -226,19 +226,19 @@ Then, whenever you want to update homebrew, switch back to the master branches,
226226
git checkout master
227227
cd /usr/local/Library/Taps/homebrew/homebrew-science
228228
git checkout master
229-
229+
230230
# Update homebrew; hopefully this works without errors!
231231
brew update
232-
232+
233233
# Switch back to the caffe branches with the forumlae that you modified earlier
234234
cd /usr/local
235235
git rebase master caffe
236236
# Fix any merge conflicts and commit to caffe branch
237237
cd /usr/local/Library/Taps/homebrew/homebrew-science
238238
git rebase master caffe
239239
# Fix any merge conflicts and commit to caffe branch
240-
241-
# Done!
240+
241+
# Done!
242242

243243
At this point, you should be running the latest Homebrew packages and your Caffe-related modifications will remain in place.
244244

0 commit comments

Comments
 (0)