-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make issues for Python module (macOS) #35
Comments
Thanks for the well reviewed question. Some notes:
An important thing is that you mention changing
and checking that the found library is printed. If nothing is printed, it means that the library won't be linked anymore, which can result in the errors you are seeing. If that's the case, please revert to I have found by Googling some mentions of a similar problem: here, here, and here. It seems another possible way this issue can happen is by some version mismatch between the Python used to compile the boost you installed via homebrew and the Python you are trying to link now in the library. The links suggest using Python 3 and reinstalling boost while explicitly removing Python 2 support - maybe doing the opposite in your case may also work. Unfortunately I'm not familiar with how homebrew works, so I can't be sure. Maybe you could also try to see how the boost you installed was compiled and check if the various versions are the same. Let me know if you find anything out, hopefully we can fix this problem :) |
Ah, and as a last note: when trying something out in Since in your case this would require re-compiling everything every time, you might want to only specify the library flags Once you are able to produce a viable |
Thanks for the quick reply. Regarding your comments,
Thanks, these changes have been made. As expected, this mistake itself won't solve the error in binding Python.
I think
Sorry for the confusion. The
I did the test.
I'll try the solutions there to see if any luck. I'll keep you posted on the results. |
Ahhhhh, sorry, it was my bad for misunderstanding. I then have the strong suspicion that if you managed to compile it with the default This post suggests to just rename the Let me know if this solves it! |
This solves the problem. Thank you very much! In summary, no need to install new compiler. Apple g++ can do the work. All dependencies can be installed directly from homebrew. Changing to Only one caveat for me to make this work --- if I install lp_solve through homebrew, I need to create a folder I left my working bash file here for anyone who might be interested
|
Awesome! And thanks a lot for leaving scripts and instructions!! I'll close this issue then, if you need help for anything else feel free to open more issues :) |
I witnessed the same; with current brew, the (If the brew formula changed to place the headers under lpsolve, that would also work (but would again break if in the future some other package provider didn't do that)). |
I am unable to use Python module on macOS (I did manage to use Python module on an Ubuntu machine following the instructions on README.md)
Among the dependencies, I used homebrew to install cmake, boost, boost-build, boost-python, and eigen3; lp_solve is downloaded from sourceforge.
Since I use Python installed by homebrew, I used
-DPYTHON_LIBRARY
and-DPYTHON_INCLUDE_DIR
to direct cmake to homebrew versions of libpython2.7.dylib and Headers.To expose Python to CMakeList, I also changed
find_package(Boost ${BOOST_VERSION_REQUIRED} COMPONENTS python REQUIRED)
tofind_package(Boost ${BOOST_VERSION_REQUIRED} COMPONENTS python27 REQUIRED)
andset(BOOST_PYTHON_LIBRARY_NAME "Boost_PYTHON_LIBRARY")
toset(BOOST_PYTHON_LIBRARY_NAME "Boost_PYTHON27_LIBRARY")
By using g++ shipped with macOS (clang-1000.10.44.4), I can cmake && make. C++ examples can run without a problem. However, Python examples are not working. Specifically, I cannot "import AIToolbox" even through I have AIToolbox.dylib compiled successfully.
Ways I have tried so far to solve this problem:
-DCMAKE_C_COMPILER=/usr/local/bin/gcc-7 -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-7
to force cmake use g++-7export PATH="/usr/local/opt/make/libexec/gnubin:$PATH
to force cmake use gmakeexport LD_LIBRARY_PATH=/usr/local/Cellar/gcc\@7/7.4.0/lib/gcc/7/:/usr/local/lib/:/usr/lib/:$LD_LIBRARY_PATH
to direct python to the gcc-7 libstdc++Overall, my script for build is as follows:
By doing so, I am able to use g++-7 as required. However, I came across linking errors both during cmake and make (stopped at 47%). The details are as follows:
Upon using the script (i.e. cmake), the output is
Running
make
in build folder results in error at Linking CXX shared library ../AIToolbox.dylib:The text was updated successfully, but these errors were encountered: