[petsc-users] Doubt about distribution of PETSc in a CMake project
Mark Lohry
mlohry at gmail.com
Mon Jul 25 12:54:45 CDT 2022
Sebastian, for a long time I've been using cmake's ExternalProject
capability to download and build petsc on target machines. For me it boils
down to cmake code like this, where you'll also need to set your
include/link paths accordingly.
ExternalProject_Add(
petsc_external
URL
http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-3.13.3.tar.gz
URL_MD5 874090c8ea0b117877aaaaf44916943b
BUILD_IN_SOURCE 1
SOURCE_DIR ${CMAKE_BINARY_DIR}/external/petsc/
CONFIGURE_COMMAND
${CMAKE_BINARY_DIR}/external/petsc/configure
PETSC_DIR=${CMAKE_BINARY_DIR}/external/petsc
PETSC_ARCH=${PETSC_ARCH_FLAG}
--with-cc=${MPI_C_COMPILER} --with-cxx=${MPI_CXX_COMPILER}
--with-fc=0 --with-pic=1 --download-metis --with-cxx-dialect=C++11
MAKEFLAGS=$MAKEFLAGS COPTFLAGS=${PETSC_OPT_FLAGS}
CXXOPTFLAGS=${PETSC_OPT_FLAGS} --with-mpiexec=${PETSC_MPIEXEC}
--with-debugging=${PETSC_DEBUGGING} ${PETSC_64_BIT_INDEX_FLAG}
BUILD_COMMAND
make -j
PETSC_DIR=${CMAKE_BINARY_DIR}/external/petsc/
PETSC_ARCH=${PETSC_ARCH_FLAG}
INSTALL_COMMAND ""
)
On Mon, Jul 25, 2022 at 11:59 AM Satish Balay via petsc-users <
petsc-users at mcs.anl.gov> wrote:
> Sorry - don't know how to help with cmake.
>
> does 'make check' work for this static build of PETSc? Also can you 'rm
> -rf PETSC_ARCH' [and rebuild PETSc] - to make sure the static build is
> clean - before you attempt your build?
>
> Also is this cmake build for your application - or a different package?
>
> It appears to be using an old version of FindPETSc.cmake - you might need
> a newer version - that uses pkg-config [but don't know the details]
>
> cc: Jed
>
> Satish
>
> On Mon, 25 Jul 2022, Sebastian Gutierrez wrote:
>
> > Hello Satish,
> >
> > First of all, I want to thank you for your response. I have been trying
> to
> > perform the second alternative you suggested, but I am having problem
> while
> > I am executing the cmake command. Could you help me with it? I got this
> > error in the image attached, additionally I config petsc with this
> > configuration: *./configure --with-cc=gcc --with-cxx=g++
> --with-fc=gfortran
> > --with-debugging=0 COPTFLAGS='-O3 -march=native -mtune=native'
> > CXXOPTFLAGS='-O3 -march=native -mtune=native' FOPTFLAGS='-O3
> -march=native
> > -mtune=native' --with-shared-libraries=0 --download-mpich*
> > And this cmake command: *cmake -DPETSC_DIR=/usr/lib/petsc-3.17.2
> > -DPETSC_ARCH=arch-linux-c-opt all -DPETSC_CURRENT=ON ../*
> >
> > I hope you can help me, please.
> >
> > Best regards,
> >
> > Sebastian
> >
> > [image: imagen.png]
> >
> >
> > El jue, 21 jul 2022 a las 15:41, Satish Balay (<balay at mcs.anl.gov>)
> > escribió:
> >
> > > Another alternative: you can install PETSc with:
> > >
> > > --with-shared-libraries=0
> > >
> > > [but some of the dependent libraries might still be shared - if so -
> > > you'll need to figure out static build for them. If they are installed
> with
> > > --download-pkg option of configure - likely it will be static]
> > >
> > > Satish
> > >
> > > On Thu, 21 Jul 2022, Satish Balay via petsc-users wrote:
> > >
> > > > You can try:
> > > >
> > > > ldd your-executable
> > > >
> > > > And copy over all the .so files listed by it [ignoring the system
> > > libraries - that might be present on the remote machine
> > > >
> > > >
> > > > Try setting LD_LIBRARY_PATH to this location [n the new machine]
> > > >
> > > > and retry 'ldd your-executable' on the new machine - and make sure
> there
> > > are no 'not found' libraries in that list
> > > >
> > > > then your-executable is likely to work.
> > > >
> > > > Note: this might not work parallely - as you would need mpiexec for a
> > > parallel run
> > > >
> > > > Satish
> > > >
> > > > On Thu, 21 Jul 2022, Sebastian Gutierrez wrote:
> > > >
> > > > >
> > > > >
> > > > >
> > > > > Good afternoon PETSc Development Team,
> > > > >
> > > > >
> > > > >
> > > > > I have been trying to distribute your program as third party
> library
> > > in my CMake Project. Because I do not want to my Linux users to have to
> > > install petsc by their own. I just want them to use my final
> > > > > product that uses petsc dependencies. When I execute make install
> of
> > > my Project in my own machine, it works perfectly but the problem
> appears
> > > when I move the executable to another machine that does not have
> > > > > installed petsc.
> > > > >
> > > > >
> > > > >
> > > > > I honestly have no idea to solve this. I wrote this email in hopes
> > > that you kindly help me out with this.
> > > > >
> > > > > I am looking forward to your answer.
> > > > >
> > > > >
> > > > >
> > > > > Best regards,
> > > > >
> > > > >
> > > > >
> > > > > Sebastian Gutierrez
> > > > >
> > > > >
> > > > >
> > > >
> > >
> >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20220725/33d305fe/attachment.html>
More information about the petsc-users
mailing list