I run cmake with PETSc feature on and I get this error:
CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find PETSc: Found unsuitable version "", but required is at least
"3.15" (found FALSE)
Call Stack (most recent call first):
/usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:592 (_FPHSA_FAILURE_MESSAGE)
cmake/modules/FindPETSc.cmake:85 (find_package_handle_standard_args)
CMakeLists.txt:235 (find_package)
I did export petsc following the precice docs with:
I assume that this code from the master branch does not contain any version information, that’s why CMake reports that it found something, but the version is just an empty string.
I tried both of your recommendations and with a release version of precise but I keep getting the same error.
I don’t know if this is relevant but I configured another project with petsc not too long ago with the same export commands and things worked well. I also don’t know if this is relevant either but I have a main directory called PRECICE and inside it I have precise, petsc, eigen, and a build directory I want to build precise in. Any hints?
Since v3, preCICE uses pkg-config to locate PETSc, so it’s easiest to start from there.
Use pkg-config --modversion PETSc to see what version pkg-config can find. If this fails, then you need to modify PKG_CONFIG_PATH or fix the PETSc installation.
Then check PKG_CONFIG_SYSTEM_INCLUDE_PATH=1 pkg-config --cflags PETSc to see if the paths are correct
Then check PKG_CONFIG_SYSTEM_LIBRARY_PATH=1 pkg-config --libs PETSc to see if the -L paths are correct.
Delete CMakeCache.txt in the binary/build directory and try again.
Also note that (unless something changed recent) if you use a --prefix to configure PETSc, then the pkg-config files will only work when you install PETSc.
If you don’t specify a prefix, then pkg-config files only work from the build directory.
Also, is there any reason you don’t use petsc-real-dev from the Ubuntu repos?
When I tried to install precice with petsc in cluster, I receive warning and errors like:
[ 0%] Built target GitRevision
[ 0%] Linking CXX static library libfmtlib-static.a
[ 0%] Built target fmtlib-static
[ 0%] Building CXX object CMakeFiles/preciceCore.dir/src/precice/impl/versions.cpp.o
[ 1%] Building CXX object CMakeFiles/preciceCore.dir/src/acceleration/Acceleration.cpp.o
[ 0%] Building CXX object CMakeFiles/preciceCore.dir/src/acceleration/AitkenAcceleration.cpp.o
[ 1%] Building CXX object CMakeFiles/preciceCore.dir/src/acceleration/ConstantRelaxationAcceleration.cpp.o
[ 1%] Building CXX object CMakeFiles/preciceCore.dir/src/acceleration/IQNILSAcceleration.cpp.o
[ 1%] Building CXX object CMakeFiles/preciceCore.dir/src/acceleration/config/AccelerationConfiguration.cpp.o
[ 1%] Building CXX object CMakeFiles/preciceCore.dir/src/acceleration/impl/ConstantPreconditioner.cpp.o
[ 2%] Building CXX object CMakeFiles/preciceCore.dir/src/acceleration/impl/ParallelMatrixOperations.cpp.o
[ 2%] Building CXX object CMakeFiles/preciceCore.dir/src/acceleration/BaseQNAcceleration.cpp.o
[ 2%] Building CXX object CMakeFiles/preciceCore.dir/src/acceleration/IQNIMVJAcceleration.cpp.o
cc1plus: warning: command line option ‘-std=c99’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-std=c99’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-std=c99’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-std=c99’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-std=c99’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-std=c99’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-std=c99’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-std=c99’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-std=c99’ is valid for C/ObjC but not for C++
cc1plus: warning: command line option ‘-std=c99’ is valid for C/ObjC but not for C++
/public/home/chenshunhua/local/petsc/include/petscvec.h: In function ‘PetscErrorCode VecCUDAReplaceArray(Vec, const PetscScalar*)’:
/public/home/chenshunhua/local/petsc/include/petscvec.h:1002:1: error: ‘PETSC_FUNCTION_NAME_CXX’ was not declared in this scope; did you mean ‘PETSC_FUNCTION_NAME_C’?
1002 | VEC_CUDA_DECL_OR_STUB(PetscErrorCode VecCUDAReplaceArray(Vec a, const PetscScalar b[]), (void)a, (void)b)
| ^~~~~~~~~~~~~~~~~~~~~
/public/home/chenshunhua/local/petsc/include/petscvec.h: In function ‘PetscErrorCode VecHIPReplaceArray(Vec, const PetscScalar*)’:
/public/home/chenshunhua/local/petsc/include/petscvec.h:1003:1: error: ‘PETSC_FUNCTION_NAME_CXX’ was not declared in this scope; did you mean ‘PETSC_FUNCTION_NAME_C’?
1003 | VEC_HIP__DECL_OR_STUB(PetscErrorCode VecHIPReplaceArray(Vec a, const PetscScalar b[]), (void)a, (void)b)
| ^~~~~~~~~~~~~~~~~~~~~
/public/home/chenshunhua/local/petsc/include/petscvec.h: In function ‘PetscErrorCode VecCUDAResetArray(Vec)’:
/public/home/chenshunhua/local/petsc/include/petscvec.h:1005:1: error: ‘PETSC_FUNCTION_NAME_CXX’ was not declared in this scope; did you mean ‘PETSC_FUNCTION_NAME_C’?
1005 | VEC_CUDA_DECL_OR_STUB(PetscErrorCode VecCUDAResetArray(Vec a), (void)a)
| ^~~~~~~~~~~~~~~~~~~~~
/public/home/chenshunhua/local/petsc/include/petscvec.h: In function ‘PetscErrorCode VecHIPResetArray(Vec)’:
/public/home/chenshunhua/local/petsc/include/petscvec.h:1006:1: error: ‘PETSC_FUNCTION_NAME_CXX’ was not declared in this scope; did you mean ‘PETSC_FUNCTION_NAME_C’?
1006 | VEC_HIP__DECL_OR_STUB(PetscErrorCode VecHIPResetArray(Vec a), (void)a)
| ^~~~~~~~~~~~~~~~~~~~~
This is a question for PETSc devs, but as far as I can tell, this means that PETSc was configured without C++. So either --with-cxx=0, with an invalid C++ compiler, or it wasn’t able to find a working C++ compiler.
I couldn’t get it to work compiling petsc from source so I installed petsc dev and precice seems to copile now.
Also, is there any reason you don’t use petsc-real-dev from the Ubuntu repos
First time I installed petsc I did it that way so I got into the habit of compiling petsc from source.
Now I don’t want to installed petsc-dev because I am afraid that it will interfere with my other builds.
In general, using system libraries consistently will lead to less guess work and less problems.
I would always advise to use system libraries unless you really need a newer version.