Difficulty building the project from source on Mac
EllingtonKirby opened this issue · 2 comments
Hey! Thanks for your awesome work on this project. I am working with the Leiden algorithm for a research project, so I wanted to make some minor modifications to the C++ source. As such I followed the build instructions from the repo.
I was able to get everything working in the end, but I wanted to let you know the additional steps I took, to see if there was an error I made that would have simplified the process.
For reference, I am using Mac OS 12.5.1.
Here are the steps I took:
- I exited my conda environment (I had issues with this previously)
- Build the
igraph
source via./scripts/build_igraph.sh
- Build the
leidenalg
source via./scripts/build_libleidenalg.sh
- I then attempted to run
python3 setup.py build
andpython3 setup.py install
but both failed with the error
clang: error: invalid version number in 'MACOSX_DEPLOYMENT_TARGET=12'
error: command '/usr/bin/gcc' failed with exit code 1
- I then re-opened my conda environment and used
pip install .
which worked successfully - Finally when trying to use the library I encountered the error
ImportError: dlopen(/Users/ellington/opt/anaconda3/envs/m1-stage-contig-constr-clustering/lib/python3.11/site-packages/leidenalg/_c_leiden.cpython-311-darwin.so, 0x0002): Library not loaded: '@rpath/liblibleidenalg.1.dylib'
Referenced from: '/Users/ellington/opt/anaconda3/envs/m1-stage-contig-constr-clustering/lib/python3.11/site-packages/leidenalg/_c_leiden.cpython-311-darwin.so'
Reason: tried: '/Users/ellington/opt/anaconda3/envs/m1-stage-contig-constr-clustering/lib/liblibleidenalg.1.dylib' (no such file), '/Users/ellington/opt/anaconda3/envs/m1-stage-contig-constr-clustering/lib/liblibleidenalg.1.dylib' (no such file), '/Users/ellington/opt/anaconda3/envs/m1-stage-contig-constr-clustering/lib/liblibleidenalg.1.dylib' (no such file), '/Users/ellington/opt/anaconda3/envs/m1-stage-contig-constr-clustering/lib/liblibleidenalg.1.dylib' (no such file), '/Users/ellington/opt/anaconda3/envs/m1-stage-contig-constr-clustering/bin/../lib/liblibleidenalg.1.dylib' (no such file), '/Users/ellington/opt/anaconda3/envs/m1-stage-contig-constr-clustering/bin/../lib/liblibleidenalg.1.dylib' (no such file), '/usr/local/lib/liblibleidenalg.1.dylib' (no such file), '/usr/lib/liblibleidenalg.1.dylib' (no such file)
- I was able to resolve this (and a similar error for
libigraph.3.dylib
) by just copying the relevant.dylib
files into the conda environment directory
Now everything is working well (untill I start fiddling around with the c++ source lol) but I just wanted to know if I really errored somewhere in the build process and could have avoided manually copying the .dylib
files. Hopefully this was clear, and if there is any info I can add let me know!
In principle, this would be the way to go. However, instead of moving around the .dylib
files, you could make sure you either install the .dylib
files directly in the correct location, or you could include the path where you installed the library in DYLD_LIBRARY_PATH
(note however that this will also be changed around by conda
). The install location is indicated in CMake by CMAKE_INSTALL_PREFIX
. You can check out and edit the provided build script to accommodate it to your own environment. At the moment, the build scripts also fetches the code, which is not what you'd want to do of course when you want to make changes.
Personally, what I would do is the following. First install igraph
manually to your desired location, see https://igraph.org/c/html/latest/igraph-Installation.html for more detail. Make sure to specify the build location by passing -DCMAKE_INSTALL_PREFIX=<dir>
at configuration time, where you should of course adapt <dir>
to the actual build location. Then clone this repository somewhere, and from within the repository directory you can then build it using the usual CMake steps:
mkdir build
cmake .. -DCMAKE_INSTALL_PREFIX=<dir>
cmake --build . --target install
You can then easily adapt the C++ code and test it in Python.
Good luck! Let me know if you need more help.
Thank you for the advice. I got things working using a little script I wrote, but when I try and clean things up at the end I will try and adapt your suggested method.
The included script only fetches the from github if there is no libleidenalg
directory, so it is working well for me when I already have the library.
Thank you for your help!