>From the code, it seems you need to let your users set env var PETSC_LIB_DIR
to the library location, or PETSC_DIR to the prefix path and PETSC_ARCH to
""

static PetscErrorCode PetscLoadDynamicLibrary(const char *name, PetscBool
*found)
{
char libs[PETSC_MAX_PATH_LEN], dlib[PETSC_MAX_PATH_LEN];

PetscFunctionBegin;
PetscCall(PetscStrncpy(libs, "${PETSC_LIB_DIR}/libpetsc", sizeof(libs)));
PetscCall(PetscStrlcat(libs, name, sizeof(libs)));
PetscCall(PetscDLLibraryRetrieve(PETSC_COMM_WORLD, libs, dlib, 1024,
found));
if (*found) {
PetscCall(PetscDLLibraryAppend(PETSC_COMM_WORLD, &PetscDLLibrariesLoaded,
dlib));
} else {
PetscCall(PetscStrncpy(libs, "${PETSC_DIR}/${PETSC_ARCH}/lib/libpetsc",
sizeof(libs)));
PetscCall(PetscStrlcat(libs, name, sizeof(libs)));
PetscCall(PetscDLLibraryRetrieve(PETSC_COMM_WORLD, libs, dlib, 1024,
found));
if (*found) PetscCall(PetscDLLibraryAppend(PETSC_COMM_WORLD,
&PetscDLLibrariesLoaded, dlib));
}
PetscFunctionReturn(PETSC_SUCCESS);
}

--Junchao Zhang


On Thu, Sep 21, 2023 at 4:59 PM Di Miao via petsc-users <
petsc-users@mcs.anl.gov> wrote:

> Hi Barry,
>
>
>
> I found the following snippet in PetscInitialize_DynamicLibraries:
>
>
>
> #if defined(PETSC_HAVE_THREADSAFETY)
>
>   /* These must be all initialized here because it is not safe for
> individual threads to call these initialize routines */
>
>   preload = PETSC_TRUE;
>
> #endif
>
>
>
> and ‘PetscLoadDynamicLibrary("", &found)’ is called only if preload==true
> and petsc is built as a shared lib. We have not faced this issue before we
> add ‘—with-thread-safety’.
>
>
>
> What we are doing is:
>
> Compile petsc/slepc as shared libraries, ship both executable and
> libpetsc.so libslepc.so to other users.
>
>
>
> Does this error message indicate that what we are doing is not robust and
> it is better to use static libraries instead?
>
>
>
> Thank you
>
> Di
>
>
>
> *From:* Barry Smith <bsm...@petsc.dev>
> *Sent:* Thursday, September 21, 2023 2:44 PM
> *To:* Di Miao <dim...@synopsys.com>
> *Cc:* petsc-users@mcs.anl.gov; Udit Pillai <ud...@synopsys.com>
> *Subject:* Re: [petsc-users] 'Unable to locate PETSc dynamic library'
> error
>
>
>
>
>
>    The recommended approach is to use --with-prefix=directory where you
> want PETSc installed instead of copying files manually after configure and
> make
>
>
>
>    I don't see why —with-thread-safety would affect this but
>
>
>
>
>
> On Sep 21, 2023, at 5:07 PM, Di Miao via petsc-users <
> petsc-users@mcs.anl.gov> wrote:
>
>
>
> To whom it may concern,
>
>
>
> In our build system, PETSc/SLEPc is compiled in one place and the *.so lib
> are then moved to another place for future use. Before we add the
> ‘—with-thread-safety’ flag, this works well. Now, we would like to run
> PETSc on multiple threads. As suggested by the manual, we added
> ‘—with-thread-safety’ flag. The udpated libpetsc.so leads to the following
> error message:
>
>
>
> Unable to locate PETSc dynamic library
>
>  You cannot move the dynamic libraries!
>
>
>
> My question is other than compile PETSc as a static library, is there any
> other solutions that can let us compile libpetsc.so in one place and
> distribute it to other folders without causing this error?
>
>
>
> Thank you,
>
> Di
>
>
>
> [0]PETSC ERROR: --------------------- Error Message
> --------------------------------------------------------------
>
> [0]PETSC ERROR: Unable to open file
>
> [0]PETSC ERROR: Unable to locate PETSc dynamic library
>
>  You cannot move the dynamic libraries!
>
> [0]PETSC ERROR: See https://petsc.org/release/faq/
> <https://urldefense.com/v3/__https:/petsc.org/release/faq/__;!!A4F2R9G_pg!fam7m9EAcUH3ksmrAcDKqw2b56d-5BMr-p7YSieNL7fFnEN9xuYzPbkyxhVcvvp16WSAXnrY-j8Q5wI00Q$>
>  for trouble shooting.
>
> [0]PETSC ERROR: Petsc Release Version 3.19.2, Jun 01, 2023
>
> [0]PETSC ERROR: Unknown Name on a arch-linux-c-opt named
> tcadprod39.synopsys.com by tcad Wed Sep 20 02:37:04 2023
>
> [0]PETSC ERROR: Configure options
> --with-mpi-dir=/SCRATCH/tcad/ci_2_0/workspace/incremental_build_main@2/petsc/../tcad_mpi_mpich
> --with-64-bit-indices=true
> --with-blaslapack-dir=/SCRATCH/tcad/ci_2_0/workspace/incremental_build_main@2/petsc/../mkl
> --with-shared-libraries --with-clean=true --with-debugging=0
> --with-mkl_pardiso-dir=/SCRATCH/tcad/ci_2_0/workspace/incremental_build_main@2/petsc/../mkl
> COPTFLAGS=-O3 CXXOPTFLAGS=-O3 FOPTFLAGS=-O3
> --download-mumps=/SCRATCH/tcad/ci_2_0/workspace/incremental_build_main@2/petsc/MUMPS_5.6.0.tar.gz
> --download-scalapack=/SCRATCH/tcad/ci_2_0/workspace/incremental_build_main@2/petsc/v2.2.0.tar.gz
> --with-ssl-dir=/SCRATCH/tcad/ci_2_0/workspace/incremental_build_main@2/petsc/../libressl
> --with-openmp=true --with-threadsafety=true --with-log=0
>
> [0]PETSC ERROR: #1 PetscInitialize_DynamicLibraries() at
> /SCRATCH/tcad/ci_2_0/workspace/incremental_build_main@2/petsc/petsc-3.19.2/src/sys/dll/reg.c:88
>
> [0]PETSC ERROR: #2 PetscInitialize_Common() at
> /SCRATCH/tcad/ci_2_0/workspace/incremental_build_main@2/petsc/petsc-3.19.2/src/sys/objects/pinit.c:1030
>
> [0]PETSC ERROR: #3 PetscInitialize() at
> /SCRATCH/tcad/ci_2_0/workspace/incremental_build_main@2/petsc/petsc-3.19.2/src/sys/objects/pinit.c:1276
>
> [0]PETSC ERROR: #4 SlepcInitialize() at
> /SCRATCH/tcad/ci_2_0/workspace/incremental_build_main@2/slepc/slepc-3.19.2/src/sys/slepcinit.c:264
>
> [0]PETSC ERROR: #5 EPSCreate() at
> /SCRATCH/tcad/ci_2_0/workspace/incremental_build_main@2/slepc/slepc-3.19.2/src/eps/interface/epsbasic.c:56
>
> [0]PETSC ERROR: #6 EPSCreate() at
> /SCRATCH/tcad/ci_2_0/workspace/incremental_build_main@2/slepc/slepc-3.19.2/src/eps/interface/epsbasic.c:56
>
> Start calculating extreme eigenvalues..
>
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
>
> [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation,
> probably memory access out of range
>
> [0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
>
> [0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind
> <https://urldefense.com/v3/__https:/petsc.org/release/faq/*valgrind__;Iw!!A4F2R9G_pg!fam7m9EAcUH3ksmrAcDKqw2b56d-5BMr-p7YSieNL7fFnEN9xuYzPbkyxhVcvvp16WSAXnrY-j895HpbMw$>
>  and https://petsc.org/release/faq/
> <https://urldefense.com/v3/__https:/petsc.org/release/faq/__;!!A4F2R9G_pg!fam7m9EAcUH3ksmrAcDKqw2b56d-5BMr-p7YSieNL7fFnEN9xuYzPbkyxhVcvvp16WSAXnrY-j8Q5wI00Q$>
>
> [0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and
> run
>
> [0]PETSC ERROR: to get more information on the crash.
>
> [0]PETSC ERROR: Run with -malloc_debug to check if memory corruption is
> causing the crash.
>
> application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0
>
> [unset]: write_line error; fd=-1 buf=:cmd=abort exitcode=59
>
> :
>
> system msg for write_line failure : Bad file descriptor
>
>
>

Reply via email to