<div dir="ltr">Thank you very much for your help.<br><div>My programs are as follows.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Smith, Barry F. <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> 于2019年12月9日周一 下午12:29写道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
There is something missing in the cmake process that is causing needed libraries not to be linked.<br>
<br>
Please email your program and your CMake stuff (files you use) so we can reproduce the problem and find a fix.<br>
<br>
Barry<br>
<br>
<br>
> On Dec 8, 2019, at 10:06 PM, Yingjie Wu <<a href="mailto:yjwu16@gmail.com" target="_blank">yjwu16@gmail.com</a>> wrote:<br>
> <br>
> Hi,<br>
> Thank you for your response. <br>
> 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.<br>
> with ex3.c:<br>
> yjwu@yjwu-XPS-8910:~/tem/build2$ make<br>
> Scanning dependencies of target Test1<br>
> [ 50%] Building C object CMakeFiles/Test1.dir/ex3.c.o<br>
> [100%] Linking C executable Test1<br>
> /usr/bin/ld: CMakeFiles/Test1.dir/ex3.c.o: undefined reference to symbol 'pow@@GLIBC_2.2.5'<br>
> //lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line<br>
> collect2: error: ld returned 1 exit status<br>
> CMakeFiles/Test1.dir/build.make:94: recipe for target 'Test1' failed<br>
> make[2]: *** [Test1] Error 1<br>
> CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Test1.dir/all' failed<br>
> make[1]: *** [CMakeFiles/Test1.dir/all] Error 2<br>
> Makefile:83: recipe for target 'all' failed<br>
> make: *** [all] Error 2<br>
> with ex3.cpp:<br>
> yjwu@yjwu-XPS-8910:~/tem/build2$ make<br>
> Scanning dependencies of target Test1<br>
> [ 50%] Building CXX object CMakeFiles/Test1.dir/ex3.cpp.o<br>
> [100%] Linking CXX executable Test1<br>
> /usr/bin/ld: CMakeFiles/Test1.dir/ex3.cpp.o: undefined reference to symbol 'MPI_Comm_rank'<br>
> /home/yjwu/petsc-3.12.2/arch-linux2-c-debug/lib/libmpi.so.12: error adding symbols: DSO missing from command line<br>
> collect2: error: ld returned 1 exit status<br>
> CMakeFiles/Test1.dir/build.make:94: recipe for target 'Test1' failed<br>
> make[2]: *** [Test1] Error 1<br>
> CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Test1.dir/all' failed<br>
> make[1]: *** [CMakeFiles/Test1.dir/all] Error 2<br>
> Makefile:83: recipe for target 'all' failed<br>
> make: *** [all] Error 2<br>
> Thanks,<br>
> Yingjie<br>
> <br>
> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> 于2019年12月6日周五 下午11:46写道:<br>
> It sounds like your C++ compiler is name mangling the symbol, but the library has no mangling.<br>
> Why are you using C++.<br>
> <br>
> Thanks,<br>
> <br>
> Matt<br>
> <br>
> On Fri, Dec 6, 2019 at 10:44 AM Yingjie Wu <<a href="mailto:yjwu16@gmail.com" target="_blank">yjwu16@gmail.com</a>> wrote:<br>
> Hi,<br>
> Thank you for your email.<br>
> The error in the previous program was indeed due to the missing "SNESSetFromOptions".<br>
> 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.<br>
> lerui@yu1994-ThinkPad-W520:~/tem2/build2$ cmake ..<br>
> -- The C compiler identification is GNU 5.4.0<br>
> -- The CXX compiler identification is GNU 5.4.0<br>
> -- Check for working C compiler: /usr/bin/cc<br>
> -- Check for working C compiler: /usr/bin/cc -- works<br>
> -- Detecting C compiler ABI info<br>
> -- Detecting C compiler ABI info - done<br>
> -- Detecting C compile features<br>
> -- Detecting C compile features - done<br>
> -- Check for working CXX compiler: /usr/bin/c++<br>
> -- Check for working CXX compiler: /usr/bin/c++ -- works<br>
> -- Detecting CXX compiler ABI info<br>
> -- Detecting CXX compiler ABI info - done<br>
> -- Detecting CXX compile features<br>
> -- Detecting CXX compile features - done<br>
> -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") <br>
> -- Checking for one of the modules 'PETSc'<br>
> pkg include dirs: /home/lerui/petsc-3.12.2/arch-linux2-c-debug/include;/home/lerui/petsc-3.12.2/include<br>
> pkg include libs: petsc<br>
> pkg ldflags: -L/home/lerui/petsc-3.12.2/arch-linux2-c-debug/lib;-lpetsc<br>
> -- Configuring done<br>
> -- Generating done<br>
> -- Build files have been written to: /home/lerui/tem2/build2<br>
> lerui@yu1994-ThinkPad-W520:~/tem2/build2$ make<br>
> Scanning dependencies of target main<br>
> [ 50%] Building CXX object CMakeFiles/main.dir/ex1.cpp.o<br>
> [100%] Linking CXX executable main<br>
> /usr/bin/ld: CMakeFiles/main.dir/ex1.cpp.o: undefined reference to symbol 'MPI_Comm_size'<br>
> /home/lerui/petsc-3.12.2/arch-linux2-c-debug/lib/libmpi.so.12: error adding symbols: DSO missing from command line<br>
> collect2: error: ld returned 1 exit status<br>
> CMakeFiles/main.dir/build.make:94: recipe for target 'main' failed<br>
> make[2]: *** [main] Error 1<br>
> CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/main.dir/all' failed<br>
> make[1]: *** [CMakeFiles/main.dir/all] Error 2<br>
> Makefile:83: recipe for target 'all' failed<br>
> make: *** [all] Error 2<br>
> Thanks,<br>
> Yingjie<br>
> <br>
> Jed Brown <<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>> 于2019年12月6日周五 上午10:54写道:<br>
> Yingjie Wu <<a href="mailto:yjwu16@gmail.com" target="_blank">yjwu16@gmail.com</a>> writes:<br>
> <br>
> > I'm so sorry that I've ignored your previous advices.<br>
> ><br>
> > I added a global variable that seems works:<br>
> ><br>
> ><br>
> > export<br>
> > LD_LIBRARY_PATH=/home/lerui/petcs-3.12.2/arch-linux2-c-debug/lib:$LD_LIBRARY_PATH<br>
> ><br>
> ><br>
> > How should I make petsc in a standard position?This eliminates the need to<br>
> > set global variables.<br>
> <br>
> You can configure PETSc with --prefix=/your/standard/path, then make install.<br>
> <br>
> > It seems that some of the options before running fit become unavailable:<br>
> ><br>
> ><br>
> > mpiexec -n 1 ./example01cmke -snes_view<br>
> ><br>
> ><br>
> > Options-snes _ view are not used and how should I solve this problem?<br>
> <br>
> I don't have your ex1.cpp, but presumably you didn't SNESSetFromOptions?<br>
> <br>
> <br>
> -- <br>
> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
> -- Norbert Wiener<br>
> <br>
> <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
<br>
</blockquote></div>