[petsc-users] linking to external library

Wu Degang samuelandjw at gmail.com
Tue Jun 5 22:33:54 CDT 2012


Hi,

In addition to petsc and slepc, I also need to link my program to 
external libraries such as GSL. I would like to modify the sample 
makefile in ${SLEPC_DIR}/src/eps/examples/tutorial/makefile rather than 
writing one from scratch. I modified the makefile so that

ex1: ex1.o chkopts
     -${CLINKER} -o ex1 ex1.o ${SLEPC_LIB}
     ${RM} ex1.o

becomes

ex1: ex1.o chkopts
     -${CLINKER} -o ex1 ex1.o ${SLEPC_LIB} -lgsl -L/opt/local/lib
     ${RM} ex1.o

But the linking process failed. The output:

bash-3.2$ make ex1
/Users/wudegang/petsc-3.2-p7/arch-darwin-c-debug/bin/mpic++ -o ex1.o -c 
-Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -g 
-I/Users/wudegang/petsc-3.2-p7/include 
-I/Users/wudegang/petsc-3.2-p7/arch-darwin-c-debug/include 
-I/opt/local/include -D__INSDIR__=src/eps/examples/tutorials/ 
-I/Users/wudegang/slepc-3.2-p5 
-I/Users/wudegang/slepc-3.2-p5/arch-darwin-c-debug/include 
-I/Users/wudegang/slepc-3.2-p5/include ex1.c
/Users/wudegang/petsc-3.2-p7/arch-darwin-c-debug/bin/mpic++ 
-Wl,-multiply_defined,suppress -Wl,-multiply_defined -Wl,suppress 
-Wl,-commons,use_dylibs -Wl,-search_paths_first 
-Wl,-multiply_defined,suppress -Wl,-multiply_defined -Wl,suppress 
-Wl,-commons,use_dylibs -Wl,-search_paths_first   -Wall -Wwrite-strings 
-Wno-strict-aliasing -Wno-unknown-pragmas -g  -o ex1 ex1.o 
-L/Users/wudegang/slepc-3.2-p5/arch-darwin-c-debug/lib 
-L/Users/wudegang/slepc-3.2-p5/arch-darwin-c-debug/lib -lslepc      
-L/Users/wudegang/petsc-3.2-p7/arch-darwin-c-debug/lib  -lpetsc 
-L/usr/X11R6/lib -lX11 -lpthread -llapack -lblas -lmpi_cxx -lstdc++ 
-ldl  -lgsl -L/opt/local/lib
Undefined symbols for architecture x86_64:
   "_dgelqf", referenced from:
       IPCGSBiOrthogonalization(_p_IP*, int, _p_Vec**, _p_Vec**, 
_p_Vec*, double*, double*, double*)in libslepc.a(iporthog.c.o)
   "_dormlq", referenced from:
       IPCGSBiOrthogonalization(_p_IP*, int, _p_Vec**, _p_Vec**, 
_p_Vec*, double*, double*, double*)in libslepc.a(iporthog.c.o)
   "_dlaev2", referenced from:
       EPSSolve_TS_Power(_p_EPS*)     in libslepc.a(power.c.o)
       EPSSolve_Power(_p_EPS*)     in libslepc.a(power.c.o)
   "_dlanhs", referenced from:
       EPSHessCond(int, double*, int, double*)in libslepc.a(subspace.c.o)
   "_dgetrf", referenced from:
       EPSHessCond(int, double*, int, double*)in libslepc.a(subspace.c.o)
       EPSTranslateHarmonic(int, double*, int, double, double, double*, 
double*)in libslepc.a(ks-harm.c.o)
       MatLUFactor_SeqDense(_p_Mat*, _p_IS*, _p_IS*, MatFactorInfo 
const*)in libpetsc.a(dense.c.o)
       _KSPDGMRESComputeDeflationData_DGMRES in libpetsc.a(dgmres.c.o)
       _KSPDGMRESImproveEig_DGMRES in libpetsc.a(dgmres.c.o)
       dvd_improvex_jd_proj_cuv(_dvdDashboard*, int, int, _p_Vec***, 
_p_Vec***, _p_Vec**, _p_Vec***, double**, double*, double*, double*, 
double*, int)in libslepc.a(dvd_improvex.c.o)
   "_dgetri", referenced from:
       EPSHessCond(int, double*, int, double*)in libslepc.a(subspace.c.o)
   "_dlange", referenced from:
       EPSHessCond(int, double*, int, double*)in libslepc.a(subspace.c.o)
   "_dsytrd", referenced from:
       ArrowTridFlip(int, int, double*, double*, double*, double*)in 
libslepc.a(ks-symm.c.o)
   "_dorgtr", referenced from:
       ArrowTridFlip(int, int, double*, double*, double*, double*)in 
libslepc.a(ks-symm.c.o)
   "_dsteqr", referenced from:
       ArrowTridFlip(int, int, double*, double*, double*, double*)in 
libslepc.a(ks-symm.c.o)
   "_dgetrs", referenced from:
       EPSTranslateHarmonic(int, double*, int, double, double, double*, 
double*)in libslepc.a(ks-harm.c.o)
       MatMatSolve_SeqDense(_p_Mat*, _p_Mat*, _p_Mat*)in 
libpetsc.a(dense.c.o)
       MatSolve_SeqDense(_p_Mat*, _p_Vec*, _p_Vec*)in libpetsc.a(dense.c.o)
       MatSolveTranspose_SeqDense(_p_Mat*, _p_Vec*, _p_Vec*)in 
libpetsc.a(dense.c.o)
       MatSolveAdd_SeqDense(_p_Mat*, _p_Vec*, _p_Vec*, _p_Vec*)in 
libpetsc.a(dense.c.o)
       MatSolveTransposeAdd_SeqDense(_p_Mat*, _p_Vec*, _p_Vec*, 
_p_Vec*)in libpetsc.a(dense.c.o)
       _KSPDGMRESApplyDeflation_DGMRES in libpetsc.a(dgmres.c.o)
       ...
   "_dgesvd", referenced from:
       EPSUpdateVectors(_p_EPS*, int, _p_Vec**, int, int, double*, int, 
double*, int)in libslepc.a(arnoldi.c.o)
       PCSetUp_SVD(_p_PC*)      in libpetsc.a(svd.c.o)
       KSPComputeExtremeSingularValues_GMRES(_p_KSP*, double*, 
double*)in libpetsc.a(gmreig.c.o)
   "_dlasv2", referenced from:
       EPSCleanDenseSchur(int, int, double*, int, double*, int, double*, 
double*, int, PetscBool)in libslepc.a(dvd_blas.c.o)
   "_dtgevc", referenced from:
       dvd_compute_eigenvectors(int, double*, int, double*, int, 
double*, int, double*, int, double*, int, PetscBool)in 
libslepc.a(dvd_blas.c.o)
   "_dtrevc", referenced from:
       dvd_compute_eigenvectors(int, double*, int, double*, int, 
double*, int, double*, int, double*, int, PetscBool)in 
libslepc.a(dvd_blas.c.o)
       EPSComputeVectors_Schur(_p_EPS*)     in libslepc.a(default.c.o)
       QEPComputeVectors_Schur(_p_QEP*)     in libslepc.a(qepdefault.c.o)
       DenseSelectedEvec(double*, int, double*, double*, int, PetscBool, 
int, double*)in libslepc.a(dense.c.o)
   "_dgeqrf", referenced from:
       SlepcDenseOrth(double*, int, int, int, double*, int, int*)in 
libslepc.a(dvd_blas.c.o)
       PCCreateTransferOp_ASA(__PC_ASA_level*, PetscBool)     in 
libpetsc.a(asa.c.o)
   "_dorgqr", referenced from:
       SlepcDenseOrth(double*, int, int, int, double*, int, int*)in 
libslepc.a(dvd_blas.c.o)
       PCCreateTransferOp_ASA(__PC_ASA_level*, PetscBool)     in 
libpetsc.a(asa.c.o)
   "_dpbtrf", referenced from:
       VecsOrthonormalize(_p_Vec**, int, double*, double*)in 
libslepc.a(dvd_blas.c.o)
   "_dgeevx", referenced from:
       EPSDenseNHEP(int, double*, double*, double*, double*, double*)in 
libslepc.a(dense.c.o)
   "_dstevr", referenced from:
       EPSDenseTridiagonal(int, double*, double*, double*, double*)in 
libslepc.a(dense.c.o)
   "_dtgexc", referenced from:
       EPSSortDenseSchurGeneralized(_p_EPS*, int, int, int, double*, 
double*, int, double*, double*, double*, double*)in libslepc.a(dense.c.o)
   "_dlamch", referenced from:
       EPSSortDenseSchurGeneralized(_p_EPS*, int, int, int, double*, 
double*, int, double*, double*, double*, double*)in libslepc.a(dense.c.o)
   "_dlag2", referenced from:
       EPSSortDenseSchurGeneralized(_p_EPS*, int, int, int, double*, 
double*, int, double*, double*, double*, double*)in libslepc.a(dense.c.o)
   "_dtrexc", referenced from:
       EPSSortDenseSchur(_p_EPS*, int, int, double*, int, double*, 
double*, double*)in libslepc.a(dense.c.o)
       QEPSortDenseSchur(_p_QEP*, int, int, double*, int, double*, 
double*, double*)in libslepc.a(qepdense.c.o)
   "_dhseqr", referenced from:
       EPSDenseSchur(int, int, double*, int, double*, double*, 
double*)in libslepc.a(dense.c.o)
       _KSPDGMRESComputeSchurForm_DGMRES in libpetsc.a(dgmres.c.o)
   "_dgehrd", referenced from:
       EPSDenseHessenberg(int, int, double*, int, double*)in 
libslepc.a(dense.c.o)
   "_dorghr", referenced from:
       EPSDenseHessenberg(int, int, double*, int, double*)in 
libslepc.a(dense.c.o)
   "_dsygvd", referenced from:
       EPSDenseGHEP(int, double*, double*, double*, double*)in 
libslepc.a(dense.c.o)
   "_dsyevr", referenced from:
       EPSDenseHEP(int, double*, int, double*, double*)in 
libslepc.a(dense.c.o)
   "_dggevx", referenced from:
       EPSDenseGNHEP(int, double*, double*, double*, double*, double*, 
double*)in libslepc.a(dense.c.o)
   "_dbdsdc", referenced from:
       SVDSolve_Lanczos(_p_SVD*)     in libslepc.a(gklanczos.c.o)
   "_dgesdd", referenced from:
       SVDDense(int, int, double*, double*, double*, double*)in 
libslepc.a(svddense.c.o)
   "_dpotrf", referenced from:
       MatCholeskyFactor_SeqDense(_p_Mat*, _p_IS*, MatFactorInfo 
const*)in libpetsc.a(dense.c.o)
       KSPSolve_BCGSL(_p_KSP*)      in libpetsc.a(bcgsl.c.o)
   "_dpotrs", referenced from:
       MatMatSolve_SeqDense(_p_Mat*, _p_Mat*, _p_Mat*)in 
libpetsc.a(dense.c.o)
       MatSolve_SeqDense(_p_Mat*, _p_Vec*, _p_Vec*)in libpetsc.a(dense.c.o)
       MatSolveTranspose_SeqDense(_p_Mat*, _p_Vec*, _p_Vec*)in 
libpetsc.a(dense.c.o)
       MatSolveAdd_SeqDense(_p_Mat*, _p_Vec*, _p_Vec*, _p_Vec*)in 
libpetsc.a(dense.c.o)
       MatSolveTransposeAdd_SeqDense(_p_Mat*, _p_Vec*, _p_Vec*, 
_p_Vec*)in libpetsc.a(dense.c.o)
       KSPSolve_BCGSL(_p_KSP*)      in libpetsc.a(bcgsl.c.o)
   "_dtrsen", referenced from:
       _KSPDGMRESComputeSchurForm_DGMRES in libpetsc.a(dgmres.c.o)
   "_dgerfs", referenced from:
       _KSPDGMRESApplyDeflation_DGMRES in libpetsc.a(dgmres.c.o)
   "_dgges", referenced from:
       _KSPDGMRESImproveEig_DGMRES in libpetsc.a(dgmres.c.o)
       dvd_calcpairs_projeig_qz_gen(_dvdDashboard*)      in 
libslepc.a(dvd_calcpairs.c.o)
   "_dtgsen", referenced from:
       _KSPDGMRESImproveEig_DGMRES in libpetsc.a(dgmres.c.o)
   "_dstebz", referenced from:
       KSPSolve_GLTR(_p_KSP*)     in libpetsc.a(gltr.c.o)
   "_dpttrf", referenced from:
       KSPSolve_GLTR(_p_KSP*)     in libpetsc.a(gltr.c.o)
   "_dpttrs", referenced from:
       KSPSolve_GLTR(_p_KSP*)     in libpetsc.a(gltr.c.o)
   "_dstein", referenced from:
       KSPSolve_GLTR(_p_KSP*)     in libpetsc.a(gltr.c.o)
   "_dgeev", referenced from:
       KSPComputeEigenvaluesExplicitly(_p_KSP*, int, double*, double*)in 
libpetsc.a(eige.c.o)
       KSPComputeEigenvalues_GMRES(_p_KSP*, int, double*, double*, 
int*)in libpetsc.a(gmreig.c.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: [ex1] Error 1 (ignored)
/bin/rm -f ex1.o

Wu Degang


More information about the petsc-users mailing list