coin-or / CyLP

A Python interface to CLP, CBC, and CGL to solve LPs and MIPs.
Other
182 stars 68 forks source link

specify the stdlib flag for installation on latest OSX #85

Open hanqiu92 opened 4 years ago

hanqiu92 commented 4 years ago

I tried to build CyLP from source on OSX with pip install cylp, but the complier complained with

fatal error: 'iostream' file not found

It seems that it is the problem with the standard library on OSX. I have tried two methods:

  1. specify the CXX=g++-9 CC=gcc-9 flag before pip install cylp to force pip to use the GNU gcc. The code was compiled successfully, but when I used it there were segmentation faults.
  2. in the setup.py, I added the following flags for the default Clang gcc: extra_compile_args += ['-stdlib=libc++'] extra_link_args += ['-stdlib=libc++'] And then the code could be complied and executed.

I think the above solution is customized to my own case, and it seems better if one can provide a more systematic solution (w.r.t. different OSX versions).

The related information about the OSX and Xcode/CLT version I used are provided below:

Clang: 11.0 build 1100 macOS: 10.15.3-x86_64 CLT: 11.3.1.0.1.1576735732 Xcode: 11.3.1 CLT headers: 11.3.1.0.1.1576735732

tkralphs commented 4 years ago

I was able to build without an issue on my OS X box, which has an older version of clang. I'm hesitant to just blindly implement this solution. I have on my TODO list to try to get test builds working on multiple OS X versions through Travis. I'll try to verify that the build fails on a clean VM and identify a fix. I guess you Googled around and saw that this is a common complaint. It could be something mucked up on your system.