sharc-md / sharc

The SHARC molecular dynamics (MD) program suite is an ab initio MD software package developed to study the excited-state dynamics of molecules.
https://www.sharc-md.org
GNU General Public License v3.0
59 stars 31 forks source link

Pysharc undefined symbol: get_grad_ shared object file #62

Closed MatthijsHak closed 11 months ago

MatthijsHak commented 11 months ago

Dear developers,

I have a problem using pysharc via the shared object file. After compiling sharc with pysharc I try to import pysharc, but I receive the following message:

sharc.cpython-39-x86_64-linux-gnu.so: undefined symbol: getgrad

I found that this function is defined in the /pysharc/include/interface.h file, and that the order of compiling should be correct as specified in the Makefile (I did not change anything in this file). Also when I look at the sharc_setup dir, the directory /pysharc/include should be included during compilation. So I do not know what the problem is here.

Could you help me out?

markusoppel commented 11 months ago

Hi, we have never seen this error. But anyway, the pathes you give the sharc_setup dir and the path to the definition are not correct. In Linux, these pathes should either contain the full path of the installation directory, e.g. something like: /work/homdirs/myhomedir/myharcinstallation/sharc/pysharc/include/...

or be relativ path names, which never begin with a "/" but rather a directory name or something líke ".."

It looks like you have not defined an enviroment variable which is used within the Makefile. Please have a closer look. If you cannot figure it out, please send a copy of your Makefile and the a detailed error message (command you are trying to execute, environment etc.)

Cheers, Markus

MatthijsHak commented 11 months ago

Hi Markus,

Thanks for the quick response. Sorry for confusing you, but I gave the full path. I have installed and used sharc multiple times, but now I want to use schnarc, for which I require pysharc. I followed these instructions to install sharc with pysharc:

Repository: https://github.com/schnarc/SchNarc

However, after the installation process, I encountered an issue with the shared object file. It seems that several variables are not defined properly. As a result, I encountered an error when trying to use the pysharc module:

mhakkennes@int5:~/software/ml_aimd/sharc/pysharc/bin(main)$ python pysharc_lvc.py 
Traceback (most recent call last):
  File "/gpfs/home6/mhakkennes/software/ml_aimd/sharc/pysharc/bin/pysharc_lvc.py", line 45, in <module>
    from sharc.pysharc.interface import SHARC_INTERFACE
ImportError: /home/mhakkennes/software/ml_aimd/sharc/pysharc/sharc/sharc.cpython-39-x86_64-linux-gnu.so: undefined symbol: get_grad_

To provide you with more context, my PYTHONPATH is set as follows:

/home/mhakkennes/software/ml_aimd/sharc/pysharc/sharc:/home/mhakkennes/software/ml_aimd/sharc/lib

For your reference, I have attached a zip file containing the files from the pysharc directory and a directory source for the sharc source, along with the build_info.inc and Makefile. Additionally, I included a file displaying a list of symbols from the shared object file using the nm command. Lastly, I provided the output of the "make install" command for both pysharc and sharc.

I would appreciate your assistance in resolving this issue. Please let me know if you require any further information.

sharc_compile_files.zip

Thank you for your help.

Regards, Matthijs

MatthijsHak commented 11 months ago

I managed to compile it correctly. Problem was that when I specified the full path to my python env, as specified in the instructions in schnarc, then I would get this error. However, when I used $CONDA_PREFIX it was fine. Thanks for the help!