[petsc-users] compilation problems of ex1.c

Jose E. Roman jroman at dsic.upv.es
Mon Mar 5 04:24:43 CST 2012


El 05/03/2012, a las 11:05, Degang Wu escribió:

> Hi,
> 
> I am new to petsc and slepc. Right now I am trying to compile ex1.c (http://acts.nersc.gov/slepc/example1/ex1.c.html) in Eclipse. I specified the paths of include files and libraries, but the compiler/linker still complained about undefined references.
> 
> The following is the error message:
> make all
> Building file: ../ex1.c
> Invoking: GCC C Compiler
> gcc -I/usr/include/slepc -I/usr/include/petsc -I/usr/include/mpi -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"ex1.d" -MT"ex1.d" -o"ex1.o" "../ex1.c"
> Finished building: ../ex1.c
> 
> Building target: slepc-ex1
> Invoking: GCC C Linker
> gcc -L/usr/lib/slepc -L/usr/lib/petsc -o"slepc-ex1"  ./ex1.o

                                                                 ^^^^^^^^^^^
Here you should have the libraries, such as -lslepc -lpetsc -lX11 -lpthread -llapack -lblas 
and maybe others. You may also want to use mpicc rather than gcc.

My suggestion is that you use the example makefiles provided by PETSc and SLEPc, rather than trying to build from Eclipse, unless you are an Eclipse expert and know what to do.

Jose

> ./ex1.o: In function `main':
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:43: undefined reference to `SlepcInitialize'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:45: undefined reference to `PetscOptionsGetInt'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:45: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:46: undefined reference to `PETSC_COMM_WORLD'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:46: undefined reference to `PetscPrintf'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:46: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:52: undefined reference to `PETSC_COMM_WORLD'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:52: undefined reference to `MatCreate'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:52: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:53: undefined reference to `MatSetSizes'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:53: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:54: undefined reference to `MatSetFromOptions'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:54: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:56: undefined reference to `MatGetOwnershipRange'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:56: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:62: undefined reference to `MatSetValues'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:62: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:66: undefined reference to `MatSetValues'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:66: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:70: undefined reference to `MatSetValues'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:70: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:73: undefined reference to `MatAssemblyBegin'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:73: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:74: undefined reference to `MatAssemblyEnd'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:74: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:76: undefined reference to `MatGetVecs'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:76: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:77: undefined reference to `MatGetVecs'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:77: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:85: undefined reference to `PETSC_COMM_WORLD'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:85: undefined reference to `EPSCreate'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:85: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:90: undefined reference to `EPSSetOperators'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:90: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:91: undefined reference to `EPSSetProblemType'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:91: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:96: undefined reference to `EPSSetFromOptions'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:96: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:102: undefined reference to `EPSSolve'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:102: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:106: undefined reference to `EPSGetIterationNumber'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:106: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:107: undefined reference to `PETSC_COMM_WORLD'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:107: undefined reference to `PetscPrintf'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:107: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:108: undefined reference to `EPSGetType'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:108: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:109: undefined reference to `PETSC_COMM_WORLD'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:109: undefined reference to `PetscPrintf'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:109: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:110: undefined reference to `EPSGetDimensions'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:110: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:111: undefined reference to `PETSC_COMM_WORLD'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:111: undefined reference to `PetscPrintf'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:111: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:112: undefined reference to `EPSGetTolerances'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:112: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:113: undefined reference to `PETSC_COMM_WORLD'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:113: undefined reference to `PetscPrintf'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:113: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:121: undefined reference to `EPSGetConverged'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:121: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:122: undefined reference to `PETSC_COMM_WORLD'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:122: undefined reference to `PetscPrintf'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:122: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:128: undefined reference to `PETSC_COMM_WORLD'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:128: undefined reference to `PetscPrintf'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:130: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:137: undefined reference to `EPSGetEigenpair'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:137: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:141: undefined reference to `EPSComputeRelativeError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:141: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:151: undefined reference to `PETSC_COMM_WORLD'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:151: undefined reference to `PetscPrintf'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:151: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:153: undefined reference to `PETSC_COMM_WORLD'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:153: undefined reference to `PetscPrintf'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:153: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:156: undefined reference to `PETSC_COMM_WORLD'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:156: undefined reference to `PetscPrintf'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:156: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:162: undefined reference to `EPSDestroy'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:162: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:163: undefined reference to `MatDestroy'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:163: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:164: undefined reference to `VecDestroy'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:164: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:165: undefined reference to `VecDestroy'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:165: undefined reference to `PetscError'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:166: undefined reference to `SlepcFinalize'
> /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:166: undefined reference to `PetscError'
> collect2: ld returned 1 exit status
> make: *** [slepc-ex1] Error 1
> 
> Regards,
> Wu Degang



More information about the petsc-users mailing list