Thanks Berend for your thorough response,<br><br>I have done what you have said but I still get the same error regarding "undefined references to PetscInitialize" etc. It's like I didn't include the petscksp.h file, but it's there. I even tried petsc.h to no avail.<br>
<br>I'm not sure what the compiler is referring to when it says "Undefined references to ...". What I think this is is in the assembly code generated by the compiler, there is a PetscInitialize symbol that isn't found in the library. But I'm soooooooooo confused at this point :(. How did you guys all learn how to compile this?<br>
<br>Matt <br><br><div class="gmail_quote">On Wed, Jul 27, 2011 at 4:46 PM, Berend van Wachem <span dir="ltr"><<a href="mailto:b.van-wachem@imperial.ac.uk">b.van-wachem@imperial.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Dear Matt,<br>
<br>
I use Eclipse and have eclipse make the makefiles.<br>
It is just a matter of indicating to eclipse where the PETSc headers/libraries are to be found, so if you have a C project which needs PETSc headers and libraries:<br>
<br>
To do this, click on your managed C project with the right sided mouse button, select<br>
<br>
Properties -> C/C++ Build -> Settings<br>
<br>
Then you get a new window with on the right hand side the various setting options.<br>
<br>
Select Includes, and add the required PETSc paths. In my case I have added<br>
${PETSC_DIR}/include<br>
${PETSC_DIR}/${PETSC_ARCH}/<u></u>include<br>
<br>
Then select "Libraries" under the header Linker<br>
and you should set the Library search path:<br>
${PETSC_DIR}/${PETSC_ARCH}/lib<br>
<br>
and then the libraries, in my case:<br>
m, petsc, stdc++, mpichxx, mpich, lapack, blas, gfortran, dl, rt,gcc_s, pthread, X11<br>
(you can find these easily in $PETSC_DIR/$PETSC_ARCH/<u></u>petscmachineinfo.h)<br>
<br>
The nice thing is that in eclipse you can easily switch between Debug/Release code, traverse into the PETSc source code etc. It's really a very productive tool with PETSc I've found.<br>
<br>
Let me know if you have any questions.<br>
<br>
Kind regards,<br>
<br>
Berend.<div class="im"><br>
<br>
<br>
On 07/27/2011 11:25 PM, Matt Bockman wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
Thanks everyone for the help,<br>
<br>
I was able to compile a single example in Eclipse using the provided<br>
makefile. I'm pretty new to makefiles so it's a LOT to digest. I'm now<br>
manually creating a makefile for my project in Eclipse (and I've set<br>
Eclipse up to use a makefile that I create instead of automatically<br>
generating one). Unfortunately this is a big pain but since I can't<br>
figure out how to make Eclipse automatically include a few files in the<br>
makefile I don't really have any other choices :(.<br>
<br>
Thanks again,<br>
Matt<br>
<br>
On Wed, Jul 27, 2011 at 1:43 PM, Mohammad Mirzadeh <<a href="mailto:mirzadeh@gmail.com" target="_blank">mirzadeh@gmail.com</a><br></div><div class="im">
<mailto:<a href="mailto:mirzadeh@gmail.com" target="_blank">mirzadeh@gmail.com</a>>> wrote:<br>
<br>
There two problems(I think) in this code.<br>
<br>
1) there is no main function in your source code. If this is the<br>
only file you are compiling, you need to change the function name to<br>
main.<br>
2) linking should be done after object files are created. A simple<br>
g++ call would first compile the main file and then link the object<br>
to the petsc lib i.e<br>
<br>
g++ -c -I($PETSC_INCLUDE) main.cpp<br>
g++ -o main main.o $PETSC_LIBS<br>
<br>
alternatively, you could do it in a single line if you like<br>
<br>
g++ -o main -I($PETSC_INCLUDE) main.cpp $PETSC_LIBS<br>
<br>
my point is you should link to petsc after compiling your own code.<br>
So wherever in Eclipse that you are seting the parameters, make sure<br>
the $PETSC_LIBS is in the linker option and not compiler.<br>
<br>
Mohammad<br>
<br>
<br>
On Wed, Jul 27, 2011 at 12:39 PM, Matt Bockman <<a href="mailto:mdbockma@ucsd.edu" target="_blank">mdbockma@ucsd.edu</a><br></div><div><div></div><div class="h5">
<mailto:<a href="mailto:mdbockma@ucsd.edu" target="_blank">mdbockma@ucsd.edu</a>>> wrote:<br>
<br>
I added the include directories from "make getincludedirs" and I<br>
added the line from "make getlinklib". Eclipse creates a gcc<br>
call as follows:<br>
<br>
/home/mdbockman/Documents/<u></u>Research/codes/petsc/petsc-3.<u></u>1-p8/linux-gnu-c-debug/bin/<u></u>mpicc<br>
-I/home/mdbockman/Documents/<u></u>Research/codes/petsc/petsc-3.<u></u>1-p8/linux-gnu-c-debug/include<br>
-I/home/mdbockman/Documents/<u></u>Research/codes/petsc/petsc-3.<u></u>1-p8/include<br>
-I/home/mdbockman/Documents/<u></u>Research/codes/petsc/petsc-3.<u></u>1-p8/linux-gnu-c-debug/include<br>
-O0 -g3 -pg -p -Wall<br>
-Wl,-rpath,/home/mdbockman/<u></u>Documents/Research/codes/<u></u>petsc/petsc-3.1-p8/linux-gnu-<u></u>c-debug/lib<br>
-Wl,-rpath,/home/mdbockman/<u></u>Documents/Research/codes/<u></u>petsc/petsc-3.1-p8/linux-gnu-<u></u>c-debug/lib<br>
-L/home/mdbockman/Documents/<u></u>Research/codes/petsc/petsc-3.<u></u>1-p8/linux-gnu-c-debug/lib<br>
-lpetsc -lX11<br>
-Wl,-rpath,/home/mdbockman/<u></u>Documents/Research/codes/<u></u>petsc/petsc-3.1-p8/linux-gnu-<u></u>c-debug/lib<br>
-L/home/mdbockman/Documents/<u></u>Research/codes/petsc/petsc-3.<u></u>1-p8/linux-gnu-c-debug/lib<br>
-lflapack -lfblas -lnsl -lrt -lm<br>
-L/home/mdbockman/Documents/<u></u>Research/codes/petsc/petsc-3.<u></u>1-p8/linux-gnu-c-debug/lib<br>
-L/usr/lib/x86_64-linux-gnu/<u></u>gcc/x86_64-linux-gnu/4.5.2<br>
-L/usr/lib/x86_64-linux-gnu -ldl -lmpich -lpthread -lrt -lgcc_s<br>
-lmpichf90 -lgfortran -lm -lm -ldl -lmpich -lpthread -lrt<br>
-lgcc_s -ldl -MMD -MP -MF"SparseMatrixPetsc.d"<br>
-MT"SparseMatrixPetsc.d" -o"SparseMatrixPetsc.o"<br>
"../SparseMatrixPetsc.c<br>
<br>
And when it is compiled I get the following:<br>
<br>
<a href="http://pastebin.com/CbRzYcZj" target="_blank">http://pastebin.com/CbRzYcZj</a><br>
<br>
The source file which is being compiled is:<br>
<br>
<a href="http://pastebin.com/Q85hXvnS" target="_blank">http://pastebin.com/Q85hXvnS</a><br>
<br>
Please have a look. I'm not quite sure what I'm doing wrong but<br>
I feel like I'm getting closer and closer to the solution.<br>
<br>
Matt<br>
<br>
<br>
On Wed, Jul 27, 2011 at 11:52 AM, Satish Balay<br></div></div><div class="im">
<<a href="mailto:balay@mcs.anl.gov" target="_blank">balay@mcs.anl.gov</a> <mailto:<a href="mailto:balay@mcs.anl.gov" target="_blank">balay@mcs.anl.gov</a>>> wrote:<br>
<br>
use:<br>
make getincludedirs<br>
<br>
Satish<br>
<br>
On Wed, 27 Jul 2011, Mohammad Mirzadeh wrote:<br>
<br>
> I applogize for the mistake; Include files are actually<br>
located<br>
> in $PETSC_DIR/include<br>
><br>
> On Wed, Jul 27, 2011 at 11:18 AM, Mohammad Mirzadeh<br></div>
<<a href="mailto:mirzadeh@gmail.com" target="_blank">mirzadeh@gmail.com</a> <mailto:<a href="mailto:mirzadeh@gmail.com" target="_blank">mirzadeh@gmail.com</a>>><u></u>wrote:<div class="im"><br>
><br>
> > Ok then. Now I don't have enough experience with Eclipse so<br>
> > I apologize beforehand if you already know these/have<br>
tried them out. If<br>
> > not, hopefully they can be of help. I assume there<br>
should be a way in<br>
> > Eclipse to give it the link lib directory. In plain<br>
makefile that's just a<br>
> > simple step when linking. To get all the needed<br>
linklibs for petsc, you can<br>
> > do<br>
> ><br>
> > make getlinklibs<br>
> ><br>
> > in the $PETSC_DIR. As for the needed include files,<br>
they are all located<br>
> > in<br>
> ><br>
> > $PETSC_DIR/$PETSC_ARCH/include<br>
> ><br>
> > Again, its easy to use these directories along with<br>
your makefile. I'm not<br>
> > sure about how you give them to Eclipse though.<br>
Hopefully this has been<br>
> > helpful.<br>
> ><br>
> > Best,<br>
> > Mohammad<br>
> ><br>
> ><br>
> ><br>
> ><br>
> > On Wed, Jul 27, 2011 at 10:52 AM, Matt Bockman<br></div><div class="im">
<<a href="mailto:mdbockma@ucsd.edu" target="_blank">mdbockma@ucsd.edu</a> <mailto:<a href="mailto:mdbockma@ucsd.edu" target="_blank">mdbockma@ucsd.edu</a>>> wrote:<br>
> ><br>
> >> Just pointing it to the library would be sufficient.<br>
> >><br>
> >> Matt<br>
> >><br>
> >><br>
> >> On Wed, Jul 27, 2011 at 10:21 AM, Mohammad Mirzadeh<br></div>
<<a href="mailto:mirzadeh@gmail.com" target="_blank">mirzadeh@gmail.com</a> <mailto:<a href="mailto:mirzadeh@gmail.com" target="_blank">mirzadeh@gmail.com</a>>><u></u>wrote:<div class="im"><br>
> >><br>
> >>> So do you want to be able to compile PETSc with<br>
Eclipse or just point it<br>
> >>> to the library to use in your own applications?<br>
> >>><br>
> >>><br>
> >>> On Wed, Jul 27, 2011 at 9:14 AM, Matt Bockman<br></div><div class="im">
<<a href="mailto:mdbockma@ucsd.edu" target="_blank">mdbockma@ucsd.edu</a> <mailto:<a href="mailto:mdbockma@ucsd.edu" target="_blank">mdbockma@ucsd.edu</a>>> wrote:<br>
> >>><br>
> >>>> Thanks Mohammad,<br>
> >>>><br>
> >>>> I'll give that a shot. I use Qt Creator for some GUI<br>
applications so I<br>
> >>>> am familiar with it, but I've never tried doing a<br>
non-Qt project in it. I'd<br>
> >>>> really like to get Eclipse to work.<br>
> >>>><br>
> >>>> Regarding the makefiles for eclipse. There are<br>
makefiles that it<br>
> >>>> generates (which are for GNU make) but I think I can<br>
also manually create my<br>
> >>>> makefiles. After sleeping on it, it seems like this<br>
might be the best<br>
> >>>> option, unless I can figure out a way to configure<br>
eclipse to include the<br>
> >>>> conf/variables and conf/rules files in the makefile.<br>
> >>>><br>
> >>>> Matt<br>
> >>>><br>
> >>>><br>
> >>>> On Wed, Jul 27, 2011 at 12:01 AM, Mohammad Mirzadeh<br></div>
<<a href="mailto:mirzadeh@gmail.com" target="_blank">mirzadeh@gmail.com</a> <mailto:<a href="mailto:mirzadeh@gmail.com" target="_blank">mirzadeh@gmail.com</a>><div class="im"><br>
> >>>> > wrote:<br>
> >>>><br>
> >>>>> Although this is sort of orthogonal to what you do<br>
right now,<br>
> >>>>> I recommend Qt Creator as an alternative IDE to<br>
Eclipse. It links nicely<br>
> >>>>> with PETSc(or any other library for that matter)<br>
and has excellent c/c++<br>
> >>>>> support.<br>
> >>>>><br>
> >>>>> Mohammad<br>
> >>>>><br>
> >>>>><br>
> >>>>> On Tue, Jul 26, 2011 at 7:22 PM, Barry Smith<br></div>
<<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a> <mailto:<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>>><u></u>wrote:<div class="im"><br>
> >>>>><br>
> >>>>>><br>
> >>>>>> There is a tiny bit of information in the PETSc<br>
users manual about<br>
> >>>>>> Eclipse:<br>
> >>>>>><br>
> >>>>>> \section{Eclipse Users} \sindex{eclipse}<br>
> >>>>>><br>
> >>>>>> If you are interested in developing code that uses<br>
PETSc from Eclipse<br>
> >>>>>> or developing PETSc in Eclipse and have knowledge<br>
of how to do indexing and<br>
> >>>>>> build libraries in Eclipse please contact us at \<br>
> >>>>>> <a href="mailto:trl%7Bpetsc-dev@mcs.anl.gov" target="_blank">trl{petsc-dev@mcs.anl.gov</a><br></div>
<mailto:<a href="mailto:trl%257Bpetsc-dev@mcs.anl.gov" target="_blank">trl%7Bpetsc-dev@mcs.<u></u>anl.gov</a>>}.<div><div></div><div class="h5"><br>
> >>>>>><br>
> >>>>>> To make PETSc an Eclipse package<br>
> >>>>>> \begin{itemize}<br>
> >>>>>> \item Install the Mecurial plugin for Eclipse and<br>
then import the<br>
> >>>>>> PETSc repository to Eclipse.<br>
> >>>>>> \item elected New->Convert to C/C++ project and<br>
selected shared<br>
> >>>>>> library. After this point you can perform searchs<br>
in the code.<br>
> >>>>>> \end{itemize}<br>
> >>>>>><br>
> >>>>>> A PETSc user has provided the following steps to<br>
build an Eclipse<br>
> >>>>>> index for PETSc that can be used with their own<br>
code without compiling PETSc<br>
> >>>>>> source into their project.<br>
> >>>>>> \begin{itemize}<br>
> >>>>>> \item In the user project source directory, create<br>
a symlink to the<br>
> >>>>>> petsc/src directory.<br>
> >>>>>> \item Refresh the project explorer in Eclipse, so<br>
the new symlink is<br>
> >>>>>> followed.<br>
> >>>>>> \item Right-click on the project in the project<br>
explorer, and choose<br>
> >>>>>> "Index -> Rebuild". The index should now be build.<br>
> >>>>>> \item Right-click on the PETSc symlink in the<br>
project explorer, and<br>
> >>>>>> choose "Exclude from build..." to make sure<br>
Eclipse does not try to compile<br>
> >>>>>> PETSc with the project.<br>
> >>>>>> \end{itemize}<br>
> >>>>>><br>
> >>>>>> We'd love to have someone figure out how to do it<br>
right and include<br>
> >>>>>> that information.<br>
> >>>>>><br>
> >>>>>> Barry<br>
> >>>>>><br>
> >>>>>> On Jul 26, 2011, at 4:32 PM, Matt Bockman wrote:<br>
> >>>>>><br>
> >>>>>> > Has anyone gotten PETSc to work w/Eclipse?<br>
Eclipse nicely generates<br>
> >>>>>> all my makefiles for me for my current project<br>
(which is written in C++).<br>
> >>>>>> I'd like to link PETSc w/my application but I'm<br>
not sure how to do this.<br>
> >>>>>> ><br>
> >>>>>> > Suggestions?<br>
> >>>>>> ><br>
> >>>>>> > Thanks,<br>
> >>>>>> > Matt<br>
> >>>>>><br>
> >>>>>><br>
> >>>>><br>
> >>>><br>
> >>><br>
> >><br>
> ><br>
><br>
<br>
<br>
<br>
<br>
</div></div></blockquote>
</blockquote></div><br>