Thanks everyone for the help, <br><br>I was able to compile a single example in Eclipse using the provided makefile. I'm pretty new to makefiles so it's a LOT to digest. I'm now manually creating a makefile for my project in Eclipse (and I've set Eclipse up to use a makefile that I create instead of automatically generating one). Unfortunately this is a big pain but since I can't figure out how to make Eclipse automatically include a few files in the makefile I don't really have any other choices :(.<br>
<br>Thanks again,<br>Matt<br><br><div class="gmail_quote">On Wed, Jul 27, 2011 at 1:43 PM, Mohammad Mirzadeh <span dir="ltr"><<a href="mailto:mirzadeh@gmail.com">mirzadeh@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div dir="ltr">There two problems(I think) in this code.<div><br></div><div>1) there is no main function in your source code. If this is the only file you are compiling, you need to change the function name to main.</div>
<div>
2) linking should be done after object files are created. A simple g++ call would first compile the main file and then link the object to the petsc lib i.e</div><div><br></div><div>g++ -c -I($PETSC_INCLUDE) main.cpp</div>
<div>g++ -o main main.o $PETSC_LIBS</div><div><br></div><div>alternatively, you could do it in a single line if you like</div><div><br></div><div>g++ -o main -I($PETSC_INCLUDE) main.cpp $PETSC_LIBS</div><div><br></div><div>
my point is you should link to petsc after compiling your own code. So wherever in Eclipse that you are seting the parameters, make sure the $PETSC_LIBS is in the linker option and not compiler.</div><div><br></div><div>
<font color="#888888">
Mohammad</font><div><div></div><div class="h5"><br>
<br><div class="gmail_quote">On Wed, Jul 27, 2011 at 12:39 PM, Matt Bockman <span dir="ltr"><<a href="mailto:mdbockma@ucsd.edu" target="_blank">mdbockma@ucsd.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I added the include directories from "make getincludedirs" and I added the line from "make getlinklib". Eclipse creates a gcc call as follows:<br>
<br>/home/mdbockman/Documents/Research/codes/petsc/petsc-3.1-p8/linux-gnu-c-debug/bin/mpicc -I/home/mdbockman/Documents/Research/codes/petsc/petsc-3.1-p8/linux-gnu-c-debug/include -I/home/mdbockman/Documents/Research/codes/petsc/petsc-3.1-p8/include -I/home/mdbockman/Documents/Research/codes/petsc/petsc-3.1-p8/linux-gnu-c-debug/include -O0 -g3 -pg -p -Wall -Wl,-rpath,/home/mdbockman/Documents/Research/codes/petsc/petsc-3.1-p8/linux-gnu-c-debug/lib -Wl,-rpath,/home/mdbockman/Documents/Research/codes/petsc/petsc-3.1-p8/linux-gnu-c-debug/lib -L/home/mdbockman/Documents/Research/codes/petsc/petsc-3.1-p8/linux-gnu-c-debug/lib -lpetsc -lX11 -Wl,-rpath,/home/mdbockman/Documents/Research/codes/petsc/petsc-3.1-p8/linux-gnu-c-debug/lib -L/home/mdbockman/Documents/Research/codes/petsc/petsc-3.1-p8/linux-gnu-c-debug/lib -lflapack -lfblas -lnsl -lrt -lm -L/home/mdbockman/Documents/Research/codes/petsc/petsc-3.1-p8/linux-gnu-c-debug/lib -L/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2 -L/usr/lib/x86_64-linux-gnu -ldl -lmpich -lpthread -lrt -lgcc_s -lmpichf90 -lgfortran -lm -lm -ldl -lmpich -lpthread -lrt -lgcc_s -ldl -MMD -MP -MF"SparseMatrixPetsc.d" -MT"SparseMatrixPetsc.d" -o"SparseMatrixPetsc.o" "../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 I feel like I'm getting closer and closer to the solution.<br><font color="#888888"><br>Matt</font><div><div></div><div><br><br><div class="gmail_quote">
On Wed, Jul 27, 2011 at 11:52 AM, Satish Balay <span dir="ltr"><<a href="mailto:balay@mcs.anl.gov" target="_blank">balay@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">use:<br>
make getincludedirs<br>
<font color="#888888"><br>
Satish<br>
</font><div><div></div><div><br>
On Wed, 27 Jul 2011, Mohammad Mirzadeh wrote:<br>
<br>
> I applogize for the mistake; Include files are actually located<br>
> in $PETSC_DIR/include<br>
><br>
> On Wed, Jul 27, 2011 at 11:18 AM, Mohammad Mirzadeh <<a href="mailto:mirzadeh@gmail.com" target="_blank">mirzadeh@gmail.com</a>>wrote:<br>
><br>
> > Ok then. Now I don't have enough experience with Eclipse so<br>
> > I apologize beforehand if you already know these/have tried them out. If<br>
> > not, hopefully they can be of help. I assume there should be a way in<br>
> > Eclipse to give it the link lib directory. In plain makefile that's just a<br>
> > simple step when linking. To get all the needed linklibs for petsc, you can<br>
> > do<br>
> ><br>
> > make getlinklibs<br>
> ><br>
> > in the $PETSC_DIR. As for the needed include files, they are all located<br>
> > in<br>
> ><br>
> > $PETSC_DIR/$PETSC_ARCH/include<br>
> ><br>
> > Again, its easy to use these directories along with your makefile. I'm not<br>
> > sure about how you give them to Eclipse though. 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 <<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 <<a href="mailto:mirzadeh@gmail.com" target="_blank">mirzadeh@gmail.com</a>>wrote:<br>
> >><br>
> >>> So do you want to be able to compile PETSc with 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 <<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 applications so I<br>
> >>>> am familiar with it, but I've never tried doing a non-Qt project in it. I'd<br>
> >>>> really like to get Eclipse to work.<br>
> >>>><br>
> >>>> Regarding the makefiles for eclipse. There are makefiles that it<br>
> >>>> generates (which are for GNU make) but I think I can also manually create my<br>
> >>>> makefiles. After sleeping on it, it seems like this might be the best<br>
> >>>> option, unless I can figure out a way to configure 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 <<a href="mailto:mirzadeh@gmail.com" target="_blank">mirzadeh@gmail.com</a><br>
> >>>> > wrote:<br>
> >>>><br>
> >>>>> Although this is sort of orthogonal to what you do right now,<br>
> >>>>> I recommend Qt Creator as an alternative IDE to Eclipse. It links nicely<br>
> >>>>> with PETSc(or any other library for that matter) and has excellent c/c++<br>
> >>>>> support.<br>
> >>>>><br>
> >>>>> Mohammad<br>
> >>>>><br>
> >>>>><br>
> >>>>> On Tue, Jul 26, 2011 at 7:22 PM, Barry Smith <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>>wrote:<br>
> >>>>><br>
> >>>>>><br>
> >>>>>> There is a tiny bit of information in the PETSc users manual about<br>
> >>>>>> Eclipse:<br>
> >>>>>><br>
> >>>>>> \section{Eclipse Users} \sindex{eclipse}<br>
> >>>>>><br>
> >>>>>> If you are interested in developing code that uses PETSc from Eclipse<br>
> >>>>>> or developing PETSc in Eclipse and have knowledge 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>
> >>>>>><br>
> >>>>>> To make PETSc an Eclipse package<br>
> >>>>>> \begin{itemize}<br>
> >>>>>> \item Install the Mecurial plugin for Eclipse and then import the<br>
> >>>>>> PETSc repository to Eclipse.<br>
> >>>>>> \item elected New->Convert to C/C++ project and selected shared<br>
> >>>>>> library. After this point you can perform searchs in the code.<br>
> >>>>>> \end{itemize}<br>
> >>>>>><br>
> >>>>>> A PETSc user has provided the following steps to build an Eclipse<br>
> >>>>>> index for PETSc that can be used with their own code without compiling PETSc<br>
> >>>>>> source into their project.<br>
> >>>>>> \begin{itemize}<br>
> >>>>>> \item In the user project source directory, create a symlink to the<br>
> >>>>>> petsc/src directory.<br>
> >>>>>> \item Refresh the project explorer in Eclipse, so the new symlink is<br>
> >>>>>> followed.<br>
> >>>>>> \item Right-click on the project in the project explorer, and choose<br>
> >>>>>> "Index -> Rebuild". The index should now be build.<br>
> >>>>>> \item Right-click on the PETSc symlink in the project explorer, and<br>
> >>>>>> choose "Exclude from build..." to make sure 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 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? Eclipse nicely generates<br>
> >>>>>> all my makefiles for me for my current project (which is written in C++).<br>
> >>>>>> I'd like to link PETSc w/my application but I'm not sure how to do this.<br>
> >>>>>> ><br>
> >>>>>> > Suggestions?<br>
> >>>>>> ><br>
> >>>>>> > Thanks,<br>
> >>>>>> > Matt<br>
> >>>>>><br>
> >>>>>><br>
> >>>>><br>
> >>>><br>
> >>><br>
> >><br>
> ><br>
><br>
<br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br></div></div></div></div>
</blockquote></div><br>