cvxpy stlibc++ Installation error on MacOS Mojave

Viewed 3334

While trying to install cvxpy package using pip install on Mac, I get the following error message:

warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from cvxpy/cvxcore/src/cvxcore.cpp:15:
cvxpy/cvxcore/src/cvxcore.hpp:18:10: fatal error: 'vector' file not found
#include <vector>
^~~~~~~~
1 warning and 1 error generated.
error: command '/usr/bin/clang' failed with exit status 1

Mac is running OS Mojave.

3 Answers

I solved the issue using the following steps,

First I tried changing the flags to instruct the installation to use libc++,

CFLAGS=-stdlib=libc++ pip install cvxpy

Then it complained about having an invalid deployment target for -stdlib=libc++ (requires OS X 10.7 or later).

Then I ran the following command to set the deployment target,

export MACOSX_DEPLOYMENT_TARGET=10.10

Then running the first command(CFLAGS=-stdlib=libc++ pip install cvxpy) again installed cvxpy successfully.

I have been struggling with this all weekend and the most success I have found so far is installing cvxpy in an anaconda environment with these two lines:

conda install -c conda-forge lapack
conda install -c cvxgrp cvxpy

I had a similar error on Mojave. The problem is that the location of the headers installed by XCode command-line tools (which includes clang) have changed. I was able to get it working by adding this to my ~/.bash_profile and opening a new shell:

export CFLAGS="-I/usr/local/include -L/usr/local/lib -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include"

This adds flags to CLANG that tell it to run the xcrun command to find the headers. It also adds the homebrew openssl headers to the clang path, which may not be necessary for this case (and assumes you have them installed).

See: https://stackoverflow.com/a/52871908/8344813

Related