[petsc-users] CMake error in PETSc

Yingjie Wu yjwu16 at gmail.com
Sun Dec 8 22:06:29 CST 2019


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 at 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 at 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 <knepley at gmail.com> 于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 <yjwu16 at gmail.com> 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 at 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 at 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 <jed at jedbrown.org> 于2019年12月6日周五 上午10:54写道:
>>
>>> Yingjie Wu <yjwu16 at gmail.com> 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/
> <http://www.cse.buffalo.edu/~knepley/>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20191209/04031eb2/attachment.html>


More information about the petsc-users mailing list