<div dir="ltr">The PETSc user&#39;s manual has a section on working with Eclipse (13.10) which describes one way to add the libraries*, have you consulted this?<div><div><br></div><div>A<br><div><br></div><div>* I notice that TeX overflowed the library link line in the PDF in my copy for 3.2, but the idea should be clear</div>
<div><br><div class="gmail_quote">On Mon, Mar 5, 2012 at 1:24 PM, Jose E. Roman <span dir="ltr">&lt;<a href="mailto:jroman@dsic.upv.es">jroman@dsic.upv.es</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
El 05/03/2012, a las 11:05, Degang Wu escribió:<br>
<div class="im"><br>
&gt; Hi,<br>
&gt;<br>
&gt; I am new to petsc and slepc. Right now I am trying to compile ex1.c (<a href="http://acts.nersc.gov/slepc/example1/ex1.c.html" target="_blank">http://acts.nersc.gov/slepc/example1/ex1.c.html</a>) in Eclipse. I specified the paths of include files and libraries, but the compiler/linker still complained about undefined references.<br>

&gt;<br>
&gt; The following is the error message:<br>
&gt; make all<br>
&gt; Building file: ../ex1.c<br>
&gt; Invoking: GCC C Compiler<br>
&gt; gcc -I/usr/include/slepc -I/usr/include/petsc -I/usr/include/mpi -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF&quot;ex1.d&quot; -MT&quot;ex1.d&quot; -o&quot;ex1.o&quot; &quot;../ex1.c&quot;<br>
&gt; Finished building: ../ex1.c<br>
&gt;<br>
&gt; Building target: slepc-ex1<br>
&gt; Invoking: GCC C Linker<br>
&gt; gcc -L/usr/lib/slepc -L/usr/lib/petsc -o&quot;slepc-ex1&quot;  ./ex1.o<br>
<br>
</div>                                                                 ^^^^^^^^^^^<br>
Here you should have the libraries, such as -lslepc -lpetsc -lX11 -lpthread -llapack -lblas<br>
and maybe others. You may also want to use mpicc rather than gcc.<br>
<br>
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.<br>
<span class="HOEnZb"><font color="#888888"><br>
Jose<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
&gt; ./ex1.o: In function `main&#39;:<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:43: undefined reference to `SlepcInitialize&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:45: undefined reference to `PetscOptionsGetInt&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:45: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:46: undefined reference to `PETSC_COMM_WORLD&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:46: undefined reference to `PetscPrintf&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:46: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:52: undefined reference to `PETSC_COMM_WORLD&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:52: undefined reference to `MatCreate&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:52: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:53: undefined reference to `MatSetSizes&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:53: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:54: undefined reference to `MatSetFromOptions&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:54: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:56: undefined reference to `MatGetOwnershipRange&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:56: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:62: undefined reference to `MatSetValues&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:62: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:66: undefined reference to `MatSetValues&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:66: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:70: undefined reference to `MatSetValues&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:70: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:73: undefined reference to `MatAssemblyBegin&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:73: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:74: undefined reference to `MatAssemblyEnd&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:74: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:76: undefined reference to `MatGetVecs&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:76: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:77: undefined reference to `MatGetVecs&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:77: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:85: undefined reference to `PETSC_COMM_WORLD&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:85: undefined reference to `EPSCreate&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:85: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:90: undefined reference to `EPSSetOperators&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:90: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:91: undefined reference to `EPSSetProblemType&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:91: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:96: undefined reference to `EPSSetFromOptions&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:96: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:102: undefined reference to `EPSSolve&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:102: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:106: undefined reference to `EPSGetIterationNumber&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:106: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:107: undefined reference to `PETSC_COMM_WORLD&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:107: undefined reference to `PetscPrintf&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:107: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:108: undefined reference to `EPSGetType&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:108: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:109: undefined reference to `PETSC_COMM_WORLD&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:109: undefined reference to `PetscPrintf&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:109: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:110: undefined reference to `EPSGetDimensions&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:110: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:111: undefined reference to `PETSC_COMM_WORLD&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:111: undefined reference to `PetscPrintf&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:111: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:112: undefined reference to `EPSGetTolerances&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:112: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:113: undefined reference to `PETSC_COMM_WORLD&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:113: undefined reference to `PetscPrintf&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:113: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:121: undefined reference to `EPSGetConverged&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:121: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:122: undefined reference to `PETSC_COMM_WORLD&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:122: undefined reference to `PetscPrintf&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:122: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:128: undefined reference to `PETSC_COMM_WORLD&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:128: undefined reference to `PetscPrintf&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:130: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:137: undefined reference to `EPSGetEigenpair&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:137: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:141: undefined reference to `EPSComputeRelativeError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:141: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:151: undefined reference to `PETSC_COMM_WORLD&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:151: undefined reference to `PetscPrintf&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:151: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:153: undefined reference to `PETSC_COMM_WORLD&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:153: undefined reference to `PetscPrintf&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:153: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:156: undefined reference to `PETSC_COMM_WORLD&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:156: undefined reference to `PetscPrintf&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:156: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:162: undefined reference to `EPSDestroy&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:162: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:163: undefined reference to `MatDestroy&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:163: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:164: undefined reference to `VecDestroy&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:164: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:165: undefined reference to `VecDestroy&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:165: undefined reference to `PetscError&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:166: undefined reference to `SlepcFinalize&#39;<br>
&gt; /home/wdg/Dropbox/dev/slepc-ex1/Debug/../ex1.c:166: undefined reference to `PetscError&#39;<br>
&gt; collect2: ld returned 1 exit status<br>
&gt; make: *** [slepc-ex1] Error 1<br>
&gt;<br>
&gt; Regards,<br>
&gt; Wu Degang<br>
<br>
</div></div></blockquote></div><br></div></div></div></div>