I am trying to build Pylith from source and link it to an external dynamic library but I am facing issues.
For example, in the code below I link a simple C++ code to my dynamic library called DataLib.dylib. The executable only works if I use
install_name_tool to change the relative path of the executable file (
@rpath) to the absolute path of the library.
export DYLD_LIBRARY_PATH='/home/bin/maci64:/home/sys/os/maci64':$DYLD_LIBRARY_PATH g++ -o myCodeCxx myCodeCxx.cpp -v -std=c++11 -I/home/extern/include -L/home/extern/bin/maci64 -lDataLib # myCodeCxx will only work if I change from the relative path to the absolute: install_name_tool -change @rpath/libMatlabEngine.dylib /home/extern/bin/maci64/DataLib.dylib myCodeCxx`
When building Pylith, I modified the main Makefile that is created right after calling
./configure to include also
The whole building process finished without any errors. However, when I try to run pylith I get the following error message, which indicates that the Pylith executable did not find my dynamic library:
Traceback (most recent call last): File "/home/Install/pylith/bin/pylith", line 25, in <module> from pylith.apps.PyLithApp import PyLithApp File "/home/Install/pylith/lib/python2.7/site-packages/pylith/apps/PyLithApp.py", line 23, in <module> from PetscApplication import PetscApplication File "/home/Install/pylith/lib/python2.7/site-packages/pylith/apps/PetscApplication.py", line 27, in <module> class PetscApplication(Application): File "/home/Install/pylith/lib/python2.7/site-packages/pylith/apps/PetscApplication.py", line 41, in PetscApplication from pylith.utils.PetscManager import PetscManager File "/home/Install/pylith/lib/python2.7/site-packages/pylith/utils/PetscManager.py", line 29, in <module> import pylith.utils.petsc as petsc File "/home/Install/pylith/lib/python2.7/site-packages/pylith/utils/petsc.py", line 28, in <module> _petsc = swig_import_helper() File "/home/Install/pylith/lib/python2.7/site-packages/pylith/utils/petsc.py", line 24, in swig_import_helper _mod = imp.load_module('_petsc', fp, pathname, description) ImportError: dlopen(/home/Install/pylith/lib/python2.7/site-packages/pylith/utils/_petscmodule.so, 2): Symbol not found: _cpp_engine_cancel_feval_with_completion Referenced from: /home/Install/pylith/lib/libpylith.0.dylib Expected in: flat namespace in /home/Install/pylith/lib/libpylith.0.dylib
The error message above seems in agreement with what I find with my simple C++ code if I don’t run the
install_name_tool on the main executable file. Note that I am setting the
DYLD_LIBRARY_PATH variable to the correct locations of my library, like I did with my simple C++ code.
My questions are:
- Could you please let me know how do I find the main pylith executable file so that I can try using the
install_name_tool? when I try
which pylithI get a path to file that gives an error to
- Would you have any suggestions to fix this issue ? Perhaps a way to include the
install_name_toolon the main Makefile ?
Note the following: I repeated the same procedure on a Linux computer and everything went fine and I was able to link it to my external library, which unfortunately does not happen on macOS system.
Thanks in advance for you help.