Thank you for your response, Barry It works for me! I made some minor changes.
I found that there was no petsc.pc in my pkgconfig folder, but PETSc.pc. So I rewrote it to: execute_process ( COMMAND pkg-config PETSc ......... And the program can run and will not report an DSO error. Thanks again for your help. Yingjie Smith, Barry F. <[email protected]> 于2019年12月9日周一 下午9:56写道: > > The problem is that your Cmake file knows nothing about the MPI > compilers that are required and hence just selects some random compilers it > found in the path which do not support MPI. > > I have attached a new CMakeList.txt for you to try. > > I uses the environmental variables PETSC_DIR and PETSC_ARCH to find the > configuration file AND use the compilers from the configuration file. It > works for me, please let me know if you have trouble. > > Barry > > > > > On Dec 8, 2019, at 10:38 PM, Yingjie Wu <[email protected]> wrote: > > > > Thank you very much for your help. > > My programs are as follow > > Smith, Barry F. <[email protected]> 于2019年12月9日周一 下午12:29写道: > > > > There is something missing in the cmake process that is causing > needed libraries not to be linked. > > > > Please email your program and your CMake stuff (files you use) so we > can reproduce the problem and find a fix. > > > > Barry > > > > > > > On Dec 8, 2019, at 10:06 PM, Yingjie Wu <[email protected]> wrote: > > > > > > Hi, > > > Thank you for your response. > > > This problem has not been solved. I've been reporting errors in the > process of 'make'. The test example I used comes from: /snes /example > /tutorials/ex3.c by modifying the suffix of ex3, there will be different > error messages as following. I checked a lot of DSO problems on the > Internet and installed a lot of libraries, but the error still haven't been > solved. I was wondering if I was missing any prefix during the configure of > PETSc(I use the simplest recommended installation), but there was no > problem when the program was compiled with the 'makefile' which is > recommended. Because I need some extra libraries, I have to use cmake. > > > with ex3.c: > > > yjwu@yjwu-XPS-8910:~/tem/build2$ make > > > Scanning dependencies of target Test1 > > > [ 50%] Building C object CMakeFiles/Test1.dir/ex3.c.o > > > [100%] Linking C executable Test1 > > > /usr/bin/ld: CMakeFiles/Test1.dir/ex3.c.o: undefined reference to > symbol 'pow@@GLIBC_2.2.5' > > > //lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing > from command line > > > collect2: error: ld returned 1 exit status > > > CMakeFiles/Test1.dir/build.make:94: recipe for target 'Test1' failed > > > make[2]: *** [Test1] Error 1 > > > CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Test1.dir/all' > failed > > > make[1]: *** [CMakeFiles/Test1.dir/all] Error 2 > > > Makefile:83: recipe for target 'all' failed > > > make: *** [all] Error 2 > > > with ex3.cpp: > > > yjwu@yjwu-XPS-8910:~/tem/build2$ make > > > Scanning dependencies of target Test1 > > > [ 50%] Building CXX object CMakeFiles/Test1.dir/ex3.cpp.o > > > [100%] Linking CXX executable Test1 > > > /usr/bin/ld: CMakeFiles/Test1.dir/ex3.cpp.o: undefined reference to > symbol 'MPI_Comm_rank' > > > /home/yjwu/petsc-3.12.2/arch-linux2-c-debug/lib/libmpi.so.12: error > adding symbols: DSO missing from command line > > > collect2: error: ld returned 1 exit status > > > CMakeFiles/Test1.dir/build.make:94: recipe for target 'Test1' failed > > > make[2]: *** [Test1] Error 1 > > > CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Test1.dir/all' > failed > > > make[1]: *** [CMakeFiles/Test1.dir/all] Error 2 > > > Makefile:83: recipe for target 'all' failed > > > make: *** [all] Error 2 > > > Thanks, > > > Yingjie > > > > > > Matthew Knepley <[email protected]> 于2019年12月6日周五 下午11:46写道: > > > It sounds like your C++ compiler is name mangling the symbol, but the > library has no mangling. > > > Why are you using C++. > > > > > > Thanks, > > > > > > Matt > > > > > > On Fri, Dec 6, 2019 at 10:44 AM Yingjie Wu <[email protected]> wrote: > > > Hi, > > > Thank you for your email. > > > The error in the previous program was indeed due to the missing > "SNESSetFromOptions". > > > I use the /snes/example/tutorial/ex1.cpp as test case. However, I > found that some of the statements in the program were not compiled and > deleted the statements containing "MPI_Comm_size", but I don't know how to > solve this problem. > > > lerui@yu1994-ThinkPad-W520:~/tem2/build2$ cmake .. > > > -- The C compiler identification is GNU 5.4.0 > > > -- The CXX compiler identification is GNU 5.4.0 > > > -- Check for working C compiler: /usr/bin/cc > > > -- Check for working C compiler: /usr/bin/cc -- works > > > -- Detecting C compiler ABI info > > > -- Detecting C compiler ABI info - done > > > -- Detecting C compile features > > > -- Detecting C compile features - done > > > -- Check for working CXX compiler: /usr/bin/c++ > > > -- Check for working CXX compiler: /usr/bin/c++ -- works > > > -- Detecting CXX compiler ABI info > > > -- Detecting CXX compiler ABI info - done > > > -- Detecting CXX compile features > > > -- Detecting CXX compile features - done > > > -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") > > > -- Checking for one of the modules 'PETSc' > > > pkg include dirs: > /home/lerui/petsc-3.12.2/arch-linux2-c-debug/include;/home/lerui/petsc-3.12.2/include > > > pkg include libs: petsc > > > pkg ldflags: -L/home/lerui/petsc-3.12.2/arch-linux2-c-debug/lib;-lpetsc > > > -- Configuring done > > > -- Generating done > > > -- Build files have been written to: /home/lerui/tem2/build2 > > > lerui@yu1994-ThinkPad-W520:~/tem2/build2$ make > > > Scanning dependencies of target main > > > [ 50%] Building CXX object CMakeFiles/main.dir/ex1.cpp.o > > > [100%] Linking CXX executable main > > > /usr/bin/ld: CMakeFiles/main.dir/ex1.cpp.o: undefined reference to > symbol 'MPI_Comm_size' > > > /home/lerui/petsc-3.12.2/arch-linux2-c-debug/lib/libmpi.so.12: error > adding symbols: DSO missing from command line > > > collect2: error: ld returned 1 exit status > > > CMakeFiles/main.dir/build.make:94: recipe for target 'main' failed > > > make[2]: *** [main] Error 1 > > > CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/main.dir/all' > failed > > > make[1]: *** [CMakeFiles/main.dir/all] Error 2 > > > Makefile:83: recipe for target 'all' failed > > > make: *** [all] Error 2 > > > Thanks, > > > Yingjie > > > > > > Jed Brown <[email protected]> 于2019年12月6日周五 上午10:54写道: > > > Yingjie Wu <[email protected]> writes: > > > > > > > I'm so sorry that I've ignored your previous advices. > > > > > > > > I added a global variable that seems works: > > > > > > > > > > > > export > > > > > LD_LIBRARY_PATH=/home/lerui/petcs-3.12.2/arch-linux2-c-debug/lib:$LD_LIBRARY_PATH > > > > > > > > > > > > How should I make petsc in a standard position?This eliminates the > need to > > > > set global variables. > > > > > > You can configure PETSc with --prefix=/your/standard/path, then make > install. > > > > > > > It seems that some of the options before running fit become > unavailable: > > > > > > > > > > > > mpiexec -n 1 ./example01cmke -snes_view > > > > > > > > > > > > Options-snes _ view are not used and how should I solve this problem? > > > > > > I don't have your ex1.cpp, but presumably you didn't > SNESSetFromOptions? > > > > > > > > > -- > > > What most experimenters take for granted before they begin their > experiments is infinitely more interesting than any results to which their > experiments lead. > > > -- Norbert Wiener > > > > > > https://www.cse.buffalo.edu/~knepley/ > > > > <CMakeLists.txt><ex3.cpp> > >
