LLNL / MemSurfer

MemSurfer is a software tool to compute bilayer membrane surfaces.
GNU General Public License v3.0
24 stars 9 forks source link

Import error- undefined symbol: __gmpq_add #27

Open nambiarnik opened 8 months ago

nambiarnik commented 8 months ago

When I'm importing memsurfer, I get the following error:

ImportError: /home/nambinik/miniconda3/lib/python3.11/site-packages/memsurfer-1.1.0-py3.11-linux-x86_64.egg/memsurfer/_memsurfer_cmod.so: undefined symbol: __gmpq_add

I believe this might be due to the GMP library not being linked,

With inspiration from an earlier question #3 I added the libgmp libraries to setup.py and reinstalled memsurfer.

Specifically changed lines 228,234 and 235

include_dirs=[PATH_PM, numpy.get_include(), PATHS['boost']['include'], PATHS['eigen']['include'], PATHS['cgal']['include'], '/opt/local/include','/usr/include/x86_64-linux-gnu' ], LIBS_EXT.append('gmp') libraries=LIBS_EXT, library_dirs=[PATHS['cgal']['lib'],'/usr/lib/x86_64-linux-gnu/']

Still get the same error though. How would one go about getting around this error?

Best Nikhil

andreashlarsen commented 7 months ago

and the same issue as #24 I just tried to install again with a new student, starting the installation from scratch, but got the same error.

lunamorrow commented 6 months ago

Having the same error installing from scratch. I'm trying to set it up for someone else in my lab. She really wants to use and access Memsurfer for analysis so it would be great if someone can look into this error ASAP please!

lunamorrow commented 3 months ago

I followed these steps and then I was able to import MemSurfer. I hope this works for you too.

Hi @Rickk-B, thank you so much for replying! I've gone through the steps but unfortunately am still having issues with running python setup.py clean --all. It seems that gmp doesn't have a lib, as I am receiving:

library_dirs=[PATHS['cgal']['lib'], PATHS['gmp']['lib']],
                                        ~~~~~~~~~~~~^^^^^^^
KeyError: 'lib'

Do you have any tips? I suspect it may be an issue with my gmp install but I am not sure. I just used sudo apt-get install -y libgmp-dev, but I'll try a manual build from a tar and see if that helps.

Rickk-B commented 3 months ago

@lunamorrow, I've tried again and I think this is an easier fix than the previous one. This time I set up a new conda environment using an .yml file to ensure correct installations.

Creating the .yml file

name: simulation channels: conda-forge defaults dependencies: gcc_linux-64=7.5.0 gxx_linux-64=7.5.0 python=3.7.12 cython=0.29.24 swig=4.0.2 cmake=3.20 gmp=6.2.1 mpfr=4.1.0 numpy libxcrypt scipy mdanalysis

After creating the .yml file i followed these steps:

MemSurfer installation in clean conda environment

conda env create -f memsurfer.yml conda activate simulation

Creating symlinks to the compilers

cd $CONDA_PREFIX/bin ln -s x86_64-conda-linux-gnu-g++ g++ ln -s x86_64-conda-linux-gnu-gcc gcc cd ../

Exporting paths

export CC="$CONDA_PREFIX/bin/gcc" export CXX="$CONDA_PREFIX/bin/g++" export CC_COMPILER=which gcc export CXX_COMPILER=which g++ export LDCXXSHARED="$CXX -shared" export PATH="$CONDA_PREFIX/bin/:$PATH" export MEM_HOME="$CONDA_PREFIX/MemSurfer" export PYTHONPATH="$CONDA_PREFIX/lib/python3.7/site-packages" export LD_LIBRARY_PATH="$MEM_HOME/external/lib:$LD_LIBRARY_PATH" export CGAL_ROOT="$MEM_HOME/external" export EIGEN_ROOT="$MEM_HOME/external" export BOOST_ROOT="$MEM_HOME/external"

Verification of correct paths and versions

which gcc which g++ which python echo $PATH gcc --version g++ --version

Downloading MemSurfer

git clone https://github.com/LLNL/MemSurfer.git cd MemSurfer git clone https://github.com/mmolero/pypoisson.git cd pypoisson git clone https://github.com/mmolero/PoissonRecon_v6_13.git cd ../

Script change in setup.py

Add line 168: LIBS_EXT = ['CGAL','gmp']

Installing depencies and MemSurfer

cd $MEM_HOME ./install_deps.sh python setup.py clean --all python -m pip install .

Testing MemSurfer

import memsurfer