I installed all the libraries(basix, ffcx, ufl, petsc and slepc) and they are working very well. But when I want to import dolfinx, it is giving this error;
Python 3.8.10 (default, Sep 28 2021, 16:10:42)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dolfinx
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ekrem/Development/Fenicsx/dolfinx-complex/lib/python3.8/dist-packages/dolfinx/__init__.py", line 31, in <module>
from dolfinx.cpp import __version__
ImportError: /home/ekrem/Development/Fenicsx/dolfinx-complex/lib/python3.8/dist-packages/dolfinx/cpp.cpython-38-x86_64-
linux-gnu.so: undefined symbol:
_ZN7dolfinx3fem18create_matrix_nestERKSt6vectorIS1_IPKNS0_4FormIdEESaIS5_EESaIS7_EERKS1_IS1_INSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISH_EESaISJ_EE
I am using ubuntu 20.04. I checked this question but it didn’t help. I have installed last version of libraries.
Can you please guide me about how to fix this error?
It says you’re using a local installation of dolfinx from /home/ekrem/Development/Fenicsx/dolfinx-complex, not the ubuntu package. I guess you’ve made your own local build? In that case you’ll need to make sure your local path is included in your python path, PYTHONPATH=/home/ekrem/Development/Fenicsx/dolfinx-complex/lib/python3.8/dist-packages. You’ll probably need to do something similar with LD_LIBRARY_PATH so the linker can find your libdolfinx.so libraries.
Thanks for your reply. I have built dolfinx from source. The real build works fine. But, I need complex build. Here is the script I am using for environment variables;
I have tried the PETSC_DIR and it still persists the same error. I have upgraded my cmake during PETSc installation. Does that effect the complex dolfinx? Very interesting that the real build works like a charm…
If you’re building dolfinx from source, then you need to set PETSC_DIR to the directory containing the petsc installation that you want to use. If you don’t set it, then the dolfinx config scripts will find the default petsc, which evidently is petsc-real. You’ll need to set it to the location of your petsc-complex installation to get dolfinx building with complex numbers.
Not exactly. ~/Development/Fenicsx/petsc is a PETSc source dir, not an installation as such. You’ve got 4 builds there, the linux-gnu-* variants. You need PETSC_DIR to point to one of them.
To be fair, your combination of PETSC_DIR and PETSC_ARCH ought to work. But since it’s not, you have to try other permutations (like setting PETSC_DIR and not setting PETSC_ARCH). What is inside the linux-gnu-* dirs? Does the linux-gnu-complex-32 subdir contain a full build of petsc-complex? What is returned by
I think these installations are seperate installations for PETSC variables. By setting PETSC_ARCH and PETSC_DIR, they are just flagging which scalars will be used during petsc use.
I’m not so good with cmake commands, builds and outputs. Can you recommend and other way of installing dolfinx with complex scalars other than the above link that I have provided?
Focusing on the original error, python seems to be finding the complex module. What it’s missing is the libdolfinx.so library that contains the missing symbol. What is your current value of LD_LIBRARY_PATH when you run python? Your undefined symbol does not contain “complex” which is odd since it does on my system. Again, what did cmake report when you ran it?
Do you have admin rights to your machine? Can you install ubuntu packages?
I can install ubuntu packages, but for some packages, I need additional features which are not exist in v0.3.0. So I need to upgrade them to dev-version for each library (basix, dolfinx…)