[petsc-dev] Mat/DM dependency

Barry Smith bsmith at mcs.anl.gov
Sat Jan 2 12:41:33 CST 2010


   Does this mean that Linux shared libraries require that EVERYTHING  
in a shared library be resolved even if the executable does not have a  
chain of calls that would ever reach the functions in the shared  
library that cannot be resolved? This is certainly not true for static  
libraries. Please confirm that this DOES happen for static libraries?  
"This problem is present with every build I have where Hypre is  
enabled." It shouldn't happen for static libraries so something is  
going on that I do not understand. Perhaps there is some linux  
specific link flag that tells the linker to stop being stupid and not  
resolve things that don't need to be resolved?

    Barry

On Jan 1, 2010, at 7:09 PM, Jed Brown wrote:

> On Fri, 1 Jan 2010 16:15:54 -0600, Barry Smith <bsmith at mcs.anl.gov>  
> wrote:
>>
>> On Jan 1, 2010, at 1:19 PM, Jed Brown wrote:
>>
>>> Mat does not normally depend on DM, but a couple implementations do,
>>>
>>> $ grep -rl DAGet petsc/src/mat/impls
>>> petsc/src/mat/impls/hypre/mhyp.c
>>> petsc/src/mat/impls/adic/nladic.c
>>> petsc/src/mat/impls/adic/matadic.c
>>>
>>> So when these are enabled, all the Mat examples fail to link because
>>> PETSC_MAT_LIB does not include PETSC_DM_LIB.
>>
>>    Please explain in detail when this occurs. It does not happen to
>> me on the Apple with static, shared or dynamic libraries. Does it
>> happen when linking the example or running it? Please cut and past  
>> all
>> error messages that appear.
>
> This problem is present with every build I have where Hypre is  
> enabled.
> I normally use shared, but not dynamic so the errors show up at link
> time.
>
> $ make info |grep '^Using configure Options'
> Using configure Options: --with-zoltan-dir=/usr --download-ml --with- 
> blas-lapack-dir=/usr --download-blacs --download-chaco --with-mpi- 
> dir=/usr --download-mumps --download-superlu_dist --download-spooles  
> --with-parmetis-dir=/usr --download-hypre --with-c2html --with-hdf5- 
> dir=/usr --with-umfpack-dir=/usr --download-sundials --download- 
> scalapack --with-lgrind --with-shared --with-sowing -PETSC_ARCH=ompi  
> --download-superlu --download-spai
> $ cd src/mat/examples/tutorials && make ex1
> /usr/bin/mpicc -o ex1.o -c -fPIC -Wall -Wwrite-strings -Wno-strict- 
> aliasing -g3 -I/home/jed/petsc/ompi/include -I/home/jed/petsc/ 
> include -I/usr/include -I/usr/lib/openmpi -I/home/jed/petsc/ompi/ 
> include -D__SDIR__="src/mat/examples/tutorials/" ex1.c
> /usr/bin/mpicc -fPIC -Wall -Wwrite-strings -Wno-strict-aliasing - 
> g3   -o ex1 ex1.o -Wl,-rpath,/home/jed/petsc/ompi/lib -L/home/jed/ 
> petsc/ompi/lib -lpetscmat -lpetscvec -lpetsc    -Wl,-rpath,/usr/lib - 
> L/usr/lib -lzoltan -lX11 -Wl,-rpath,/home/jed/petsc/ompi/lib -L/home/ 
> jed/petsc/ompi/lib -lcmumps -ldmumps -lsmumps -lzmumps - 
> lmumps_common -lpord -lscalapack -lblacs -lchaco -lspooles -lHYPRE - 
> Wl,-rpath,/usr/lib/openmpi -Wl,-rpath,/usr/lib/gcc/x86_64-unknown- 
> linux-gnu/4.4.2 -lmpi_cxx -lstdc++ -lhdf5 -lz -lsuperlu_dist_2.3 - 
> lparmetis -lmetis -lml -lmpi_cxx -lstdc++ -lspai -lsundials_cvode - 
> lsundials_nvecserial -lsundials_nvecparallel -lsuperlu_4.0 -lumfpack  
> -lamd -Wl,-rpath,/usr -L/usr -llapack -lcblas -lf77blas -latlas -Wl,- 
> rpath,/usr/lib/openmpi -L/usr/lib/openmpi -Wl,-rpath,/usr/lib/gcc/ 
> x86_64-unknown-linux-gnu/4.4.2 -L/usr/lib/gcc/x86_64-unknown-linux- 
> gnu/4.4.2 -ldl -lmpi -lopen-rte -lopen-pal -lnsl -lutil -lgcc_s - 
> lpthread -lmpi_f90 -lmpi_f77 -lgfortran -lm -lm -Wl,-rpath,/usr/lib/ 
> gcc/x86_64-unknown-linux-gnu -L/usr/lib/gcc/x86_64-unknown-linux-gnu  
> -lm -lm -lmpi_cxx -lstdc++ -lmpi_cxx -lstdc++ -ldl -lmpi -lopen-rte - 
> lopen-pal -lnsl -lutil -lgcc_s -lpthread -ldl
> /home/jed/petsc/ompi/lib/libpetscmat.so: undefined reference to  
> `DAGetInfo'
> /home/jed/petsc/ompi/lib/libpetscmat.so: undefined reference to  
> `DAGetCorners'
> /home/jed/petsc/ompi/lib/libpetscmat.so: undefined reference to  
> `DAGetGhostCorners'
> /home/jed/petsc/ompi/lib/libpetscmat.so: undefined reference to  
> `DAGetGlobalIndices'
> collect2: ld returned 1 exit status
> make: [ex1] Error 1 (ignored)
> /bin/rm -f ex1.o
>
>>   Let's not get carried away with redesigning all of PETSc because of
>> a simple link issue (or crappy shared library design on Linux :-).
>
> The stuff in mhyp.c uses DA, this is a dependency loop because (1)  
> this
> file resides in src/mat and (2) it is linked into libpetscmat which we
> claim can be used without libpetscdm.
>
> Jed




More information about the petsc-dev mailing list