modmido / psiquasp

PsiQuaSP -- Permutation symmetry for identical Quantum Systems Package
Other
17 stars 2 forks source link

PsiQuasp library isn't able to include petscxyz.h files #5

Closed schaftler closed 3 years ago

schaftler commented 3 years ago

I have installed petsc and build psiquasp without any errors, but when I'm trying to run the example codes, psiquasp isn't able to include files named "petsc__.h" from the include folder. In file included from ../../include/psiquasp.hpp:12, from ex1a.hpp:12, from ex1a.cpp:14: ../../include/system.hpp:119:9: fatal error: petscvec.h: No such file or directory 119 | #include<petscvec.h> | ^~~~~~~~~~~~ compilation terminated.

This is the error when I'm trying to run an example. I also have set the environment variables correctly.

modmido commented 3 years ago

Hi there, thanks for being interested in this library. In order to be able to help you, can you tell me a little about your operating system, the compilers you use and so on? And what happened when you tried to run make on psiquasp library? Did you follow the installation instructions? Thank you

schaftler commented 3 years ago

Thank you for responding. I am using a Linux machine, with Ubuntu 20.04 LTS installed and tried using both g++ and gcc compiler. When I ran make on psiquasp, it showed that the installation was complete and psiquasp was successfully built. I made sure that I specified the PETSC_DIR and PETSC_ARCH correctly. Yes, I followed the instructions as they were provided in the INSTALL.md. I even reinstalled everything but somehow it isn't able to include the petsc header files.

modmido commented 3 years ago

Are you using relative folder paths in the options.mk file? Things like ../ or ~/ ? That can sometimes create problems, you should always use the full path like /home/yourusername/path/to/your/petsc and so on. If not can you post your options.mk file and give me more information about where and how you set up petsc and psiquasp?

schaftler commented 3 years ago

No, I am using full paths. I downloaded petsc-3.15.0 from the website mentioned in INSTALL.md.

This is the log of make all check after configuring PETSC: PETSC_build.txt

Then after completing the installation, I went to the psiquasp folder and did the following:

(base) schaftler@schaftler-GF63-Thin-9SCXR:~/Desktop/DESY_FS-TUXS_Project/Software/psiquasp$ make

Building PsiQuaSP library

make[1]: Entering directory '/home/schaftler/Desktop/DESY_FS-TUXS_Project/Software/psiquasp/src'
  Compiling src/index.cpp with optimizations
  Compiling src/dim.cpp with optimizations
  Compiling src/sutil.cpp with optimizations
  Compiling src/sliouville.cpp with optimizations
  Compiling src/smodular.cpp with optimizations
  Compiling src/output.cpp with optimizations
  Compiling src/observables.cpp with optimizations
  Compiling src/gnfcts.cpp with optimizations
  Compiling src/distributions.cpp with optimizations
  Compiling src/twolevelsystems.cpp with optimizations
ar: creating ../arch-linux-c-debug/libpsiquasp.a

  PsiQuaSP library build successful

make[1]: Leaving directory '/home/schaftler/Desktop/DESY_FS-TUXS_Project/Software/psiquasp/src'

This is the copy of options.mk file in .txt format as .mk file cannot be directly added here. options (copy).txt

modmido commented 3 years ago

Hm, strange, just to be completely sure, what command are you using to build ex1a?

schaftler commented 3 years ago

Like this:

schaftler@schaftler-GF63-Thin-9SCXR:~/Desktop/DESY_FS-TUXS_Project/Software/psiquasp/example/ex3a$ g++ *.cpp -o output
In file included from ../../include/psiquasp.hpp:12,
                 from ex3a.hpp:13,
                 from ex3a.cpp:11:
../../include/system.hpp:119:9: fatal error: petscvec.h: No such file or directory
  119 | #include<petscvec.h>
      |         ^~~~~~~~~~~~
compilation terminated.
martenrichter commented 3 years ago

Actually, this might be caused by a newer petsc version, where the header file names where rearranged. I would advise to replace the include with a more general petsc include as in the library file. Also other things may come up, since also other parts of petsc api changed, since the development of psiquasp.

schaftler commented 3 years ago

Well, the name of the header files as far as I have checked are the same that are being included in the example files. Also, could you please elaborate more on your suggestion on replacing with general petsc include? And do you think using an older petsc version would solve the issue?

martenrichter commented 3 years ago

Ok you are right they also appear in the main libary, it can not be a problem with the version...

modmido commented 3 years ago

I think we found the problem: you should use the make files for building the examples. Just run make in the examples folder and it should work. You always need to provide the path to the headers and to the linked libraries at compile time. The makefile does exactly that for you

schaftler commented 3 years ago

Ohh, even I thought so earlier, I did try running make in the example directory. But this is what I get:

(base) schaftler@schaftler-GF63-Thin-9SCXR:~/Desktop/DESY_FS-TUXS_Project/Software/psiquasp/example/ex1a$ make
/home/schaftler/Desktop/DESY_FS-TUXS_Project/Software/petsc-3.15.0/arch-linux-c-debug/bin/mpicc -std=c++0x -O0 -g -Wall ex1a.cpp -I/home/schaftler/Desktop/DESY_FS-TUXS_Project/Software/petsc-3.15.0/include -I/home/schaftler/Desktop/DESY_FS-TUXS_Project/Software/petsc-3.15.0/arch-linux-c-debug/include -L../..//arch-linux-c-debug -Wl,-rpath,/home/schaftler/Desktop/DESY_FS-TUXS_Project/Software/petsc-3.15.0/arch-linux-c-debug/lib -L/home/schaftler/Desktop/DESY_FS-TUXS_Project/Software/petsc-3.15.0/arch-linux-c-debug/lib -Wl,-rpath,/home/schaftler/Desktop/DESY_FS-TUXS_Project/Software/petsc-3.15.0/arch-linux-c-debug/lib -L/home/schaftler/Desktop/DESY_FS-TUXS_Project/Software/petsc-3.15.0/arch-linux-c-debug/lib -Wl,-rpath,/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9 -Wl,-rpath,/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -Wl,-rpath,/lib/x86_64-linux-gnu -L/lib/x86_64-linux-gnu -lpetsc -lflapack -lfblas -lpthread -lm -lX11 -lstdc++ -ldl -lmpifort -lmpi -lgfortran -lm -lgfortran -lm -lgcc_s -lquadmath -lstdc++ -ldl -lpsiquasp
/usr/bin/ld: ../..//arch-linux-c-debug/libpsiquasp.a(observables.o): undefined reference to symbol 'cexp@@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [makefile:9: ex1a] Error 1
martenrichter commented 3 years ago

Try to add -lm somewhere in the makefile, where the library options are passed.

schaftler commented 3 years ago

Yes, the first error undefined reference to symbol 'cexp@@GLIBC_2.2.5', is solved by changing the compiler to g++, namely by running make CC=g++. g++ links the math libraries automatically. But the second error still persists even after adding -lm at the library options. /usr/bin/ld: /lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make: *** [makefile:9: ex1a] Error 1

martenrichter commented 3 years ago

Do not change the compiler please. cexp is defined in normal c and not c++.

schaftler commented 3 years ago

Oh okay. But anyhow the error is unresolved. Can you please share with me the versions of PETSC and compilers that you are using? I will try running those and confirm if the error has something to do with the version.

modmido commented 3 years ago

Sorry for the delay, I got vaccinated and am a bit out of order. I reinstalled petsc (3.15) and psiquasp on my mac, that worked just fine. I could check it next week on an Ubuntu machine though. I think you should go with the makefile provided in the examples, since manually adding all the includes from Petsc can be cumbersome.

Ohh, even I thought so earlier, I did try running make in the example directory. But this is what I get:

(base) schaftler@schaftler-GF63-Thin-9SCXR:~/Desktop/DESY_FS-TUXS_Project/Software/psiquasp/example/ex1a$ make
/home/schaftler/Desktop/DESY_FS-TUXS_Project/Software/petsc-3.15.0/arch-linux-c-debug/bin/mpicc -std=c++0x -O0 -g -Wall ex1a.cpp -I/home/schaftler/Desktop/DESY_FS-TUXS_Project/Software/petsc-3.15.0/include -I/home/schaftler/Desktop/DESY_FS-TUXS_Project/Software/petsc-3.15.0/arch-linux-c-debug/include -L../..//arch-linux-c-debug -Wl,-rpath,/home/schaftler/Desktop/DESY_FS-TUXS_Project/Software/petsc-3.15.0/arch-linux-c-debug/lib -L/home/schaftler/Desktop/DESY_FS-TUXS_Project/Software/petsc-3.15.0/arch-linux-c-debug/lib -Wl,-rpath,/home/schaftler/Desktop/DESY_FS-TUXS_Project/Software/petsc-3.15.0/arch-linux-c-debug/lib -L/home/schaftler/Desktop/DESY_FS-TUXS_Project/Software/petsc-3.15.0/arch-linux-c-debug/lib -Wl,-rpath,/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9 -Wl,-rpath,/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -Wl,-rpath,/lib/x86_64-linux-gnu -L/lib/x86_64-linux-gnu -lpetsc -lflapack -lfblas -lpthread -lm -lX11 -lstdc++ -ldl -lmpifort -lmpi -lgfortran -lm -lgfortran -lm -lgcc_s -lquadmath -lstdc++ -ldl -lpsiquasp
/usr/bin/ld: ../..//arch-linux-c-debug/libpsiquasp.a(observables.o): undefined reference to symbol 'cexp@@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [makefile:9: ex1a] Error 1

What strikes me here is that it includes -lm three times and -ldl two times, there seems to be sth weird with the petsc includes. You could try to copy the command and remove all the double/triple occurences.

The root problem is that he somehow does not find the definition of PetscExpScalar, which is used by observables.cpp. Can you try to build and run the following Petsc example:

petsc/src/ts/tutorials/multirate/ex1.c

Its using complex numbers and PetscExpScalar. You could also try to downgrade to petsc 3.9, that is the version that was used to develop psiquasp.

schaftler commented 3 years ago

Hi, sorry for the delay. I tried running the example in petsc as suggested by you, it gives the same error.

Also, I tried downgrading to petsc 3.9 but it was built on Python 2, and doesn't run on systems with Python 3 as default. So instead I tried using petsc 3.11.0, but the same errors still persist. I would like to know if you tried it on Linux and if it worked correctly?

Also, is valgrind necessary to be installed for psiquasp? I do not have it, but I don't think that should be the issue.

modmido commented 3 years ago

Hi there, since it seems that it is clearly a problem with Petsc itself I would ask you to contact the Petsc developers or look online for others having the same problem, since I can't provide technical support for that library as well. And no you don't need valgrind for psiquasp, it is just a nice tool to write better/more stable code.