Permalink
Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up
Branch:master
Find file Copy path
Fetching contributors…
A recent (and even more recently reverted) change to Homebrew highlighted an interesting (read: maddening) quirk of clang on OS X. Here’s the background. When you compile something using clang on OS X there are (roughly speaking) two stages to the compile. In the first, your source code is loaded and the compiler searches its include paths to find your includes. Specifies a path that the linker will search before it searches the path specified in the LIB environment option. Use the /LIBPATH option to override the environment library path. The linker will first search in the path specified by this option, and then search in the path specified in the LIB environment variable. Only the file name of the compiler executable needs to be specified as long as it is on a path contained in the PATH variable when the Makefile is processed. QMAKECFLAGS Specifies the C compiler flags for building a project. Mar 08, 2016 Your support makes a big difference: I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs.
# -*- makefile -*- |
# Copyright (c) Facebook, Inc. and its affiliates. |
# |
# This source code is licensed under the MIT license found in the |
# LICENSE file in the root directory of this source tree. |
# Tested on macOS Sierra (10.12.2) with llvm installed using Homebrew (https://brew.sh) |
# brew install llvm |
CXX = /usr/local/opt/llvm/bin/clang++ -std=c++11 |
CXXFLAGS = -fPIC -m64 -Wall -g -O3 -fopenmp -Wno-sign-compare -I/usr/local/opt/llvm/include |
CPUFLAGS = -msse4 -mpopcnt |
LLVM_VERSION_PATH=$(shell ls -rt /usr/local/Cellar/llvm/ | tail -n1) |
LDFLAGS = -fPIC -fopenmp -L/usr/local/opt/llvm/lib -L/usr/local/Cellar/llvm/${LLVM_VERSION_PATH}/lib |
# common mac flags |
SHAREDEXT = dylib |
SHAREDFLAGS = -dynamiclib |
MKDIR_P = mkdir -p |
prefix ?= /usr/local |
exec_prefix ?= ${prefix} |
libdir = ${exec_prefix}/lib |
includedir = ${prefix}/include |
########################################################################## |
# Uncomment one of the 4 BLAS/Lapack implementation options |
# below. They are sorted # from fastest to slowest (in our |
# experiments). |
########################################################################## |
# |
# 1. Intel MKL |
# |
# This is the fastest BLAS implementation we tested. Unfortunately it |
# is not open-source and determining the correct linking flags is a |
# nightmare. See |
# |
# https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor |
# |
# The latest tested version is MKL 2017.0.098 (2017 Initial Release) and can |
# be downloaded here: |
# |
# https://registrationcenter.intel.com/en/forms/?productid=2558&licensetype=2 |
# |
# The following settings are working if MKL is installed on its default folder: |
# |
# MKLROOT = /opt/intel/compilers_and_libraries/linux/mkl/ |
# |
# LDFLAGS += -Wl,--no-as-needed -L$(MKLROOT)/lib/intel64 |
# LIBS += -lmkl_intel_ilp64 -lmkl_core -lmkl_gnu_thread -ldl -lpthread |
# |
# CPPFLAGS += -DFINTEGER=long |
# |
# You may have to set the LD_LIBRARY_PATH=$MKLROOT/lib/intel64 at runtime. |
# |
# 2. Openblas |
# |
# The library contains both BLAS and Lapack. Install with brew install OpenBLAS |
# |
# CPPFLAGS += -DFINTEGER=int |
# LIBS += /usr/local/opt/openblas/lib/libblas.dylib |
# |
# |
# 3. Apple's framework accelerate |
# |
# This has the advantage that it does not require to install anything, |
# as it is provided by default on the mac. It is not very fast, though. |
# |
CPPFLAGS += -DFINTEGER=int |
LIBS += -framework Accelerate |
########################################################################## |
# SWIG and Python flags |
########################################################################## |
# SWIG executable. This should be at least version 3.x |
# brew install swig |
SWIG = /usr/local/bin/swig |
# The Python include directories for the current python executable |
PYTHON_INC=$(shell python -c 'import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())') |
NUMPY_INC=$(shell python -c 'import numpy ; print(numpy.get_include())') |
PYTHONCFLAGS=-I${PYTHON_INC} -I${NUMPY_INC} |
PYTHONLIB=-lpython |
########################################################################## |
# Faiss GPU |
########################################################################## |
# As we don't have access to a Mac with nvidia GPUs installed, we |
# could not validate the GPU compile of Faiss. |
Copy lines Copy permalink
If I unset LDLIBRARYPATH C import works but MCR fails. So the question what LDLIBRARYPATH should be in order to run both C classes and Matlab's python package successfully? I have tried to add path to boost libraries to LDLIBRARYPATH but didn't work, so the env value would be.
July 24th, 2015 A recent (and even more recently reverted) change to Homebrew highlighted an interesting (read: maddening) quirk of clang on OS X. Here’s the background.
When you compile something using clang on OS X there are (roughly speaking) two stages to the compile. In the first, your source code is loaded and the compiler searches its include paths to find your includes. Here’s what clang’s defaults look like for the Xcode 6.4 command line tools:
How to open an Apple Music playlist in a new windowPlaylists on Apple Music cannot be opened in their separate windows unless they’re in your iTunes library.
I don’t have that many playlists created in iTunes so I was able to open “only” four playlist windows, but it worked like a charm. Thankfully, the company has reinstated the ability to open playlists in new windows with iTunes 12.6. Here’s how to open your playlists in their separate windows using iTunes for Mac. How to open your playlist in a new iTunes window1) Launch iTunes on your Mac.2) Choose Music from the menu near the upper-left corner, then click the Library tab.3) In the lefthand column, right-click or Control (⌃)-click your playlist underneath the All Playlists heading, then select the option Open In New Window from the popup menu.This will open a new iTunes window containing the selected playlist, as shown top of post.You can drag songs at will between the playlist windows and open as many playlists in separate windows as you like.
As you can see, the include search starts with
/usr/local/include
and /usr/include
is the fourth item. So, in the case of a vanilla OS X install a binary attempting to compile using OpenSSL (let’s say #include <openssl/x509.h>
) would find the OpenSSL headers in /usr/include
after searching the previous 3 locations fruitlessly.Once it’s found (and the C preprocessor has run and all the objects have been compiled) we now need to link it. When compiling something against OpenSSL you’ll link against
-lssl
, -lcrypto
, or both. These command line flags simply tell the linker to look for something named “libssl.dylib” or “libcrypto.dylib” in the library search paths. But what are those paths?This time we see two primary library search paths,
/usr/lib
and /usr/local/lib
…which are reversed in priority from our include search path.The result of this is that if you have something (like OpenSSL) that is present in both
/usr/local/{include,lib}
and /usr/{include,lib}
you’ll end up with the compiler using the headers from /usr/local/include
and then linking against the library in /usr/lib
. This can result in a variety of problems, the severity of which depend on how different the two versions of the library are and what features the binary you’re compiling is using.Mac Makefile Set Library Path Map
So why does this matter? Well, in El Capitan (10.11) Apple has chosen to remove the OpenSSL development headers, but not remove the dylibs. They deprecated use of system OpenSSL in Lion (10.7) so this makes sense on the surface, but the weird include/linker ordering means that if homebrew (or anything else living in your include/search paths) duplicates a system library bad things may occur. There are four possible paths (all of which are under the control of Apple and not us plebes):
Makefile Path With Space
- Change the linker order preference. Probably a good idea long term but likely to cause all sorts of unintended breakage as we find things that are implicitly depending on this crazy ordering.
- Re-add the OpenSSL headers for 0.9.8. Not a great option since 0.9.8 is scheduled for EOL at the end of this year and Apple has marked it deprecated in OS X since Lion (originally released July 20, 2011), but probably the safest and lowest friction option.
- Remove OpenSSL entirely. This would break any OS X app that links against it and would require Apple to ship updates to Ruby, Python, Apache, etc that statically link OpenSSL (or go down the route of a “private” dylib like they’ve done with OpenSSH in El Capitan)
- Do nothing and let this be a significant source of pain for developers during El Capitan’s lifecycle. This is the most likely scenario.
Makefile Header File Path
I favor either removing the OpenSSL dylibs entirely for El Capitan or re-adding the OpenSSL headers and then removing everything in the next major release, but I don’t envy whoever has to make this choice. Everything has downsides.