[petsc-users] Linking error with C++ code: undefined symbols

Matthew Knepley knepley at gmail.com
Wed Mar 24 05:30:18 CDT 2010


On Wed, Mar 24, 2010 at 3:02 AM, charles reid <charlesreid1 at gmail.com>wrote:

> Hi Satish -
>
> Thanks for your response. I think this helped me to realize that I was
> making things harder than they should be.
>
> I've managed to get this working, and here are a few notes:
>
> 1. It was not clear to me why the Petsc-provided makefiles worked, because
> the compilation of the C code into a ".o" file is buried deep inside several
> makefiles (e.g. $PETSC_DIR/conf/rules) included in the original example
> makefile.  So, I was trying to compile each of my ".cc" files into ".o"
> files manually, then link.  In fact, all I had to do was let Petsc take care
> of compiling each ".cc" file into a ".o" file, and I only had to give the
> line to link the libraries to the driver.
>
> 2. The only major change I had to make to the example makefiles to get the
> driver to link and compile was to add ${PETSC_CC_INCLUDES} after ${CLINKER},
> like this:
>
> Laplace: Laplace.cc $(OBJ_FILES)
>     -${CLINKER} ${PETSC_CC_INCLUDES} Laplace.cc -o bin.x $(OBJ_FILES)
> ${PETSC_KSP_LIB}
>     ${RM} $(OBJ_FILES)
>

Alternatively

Laplace: Laplace.o $(OBJ_FILES)
    -${CLINKER} -o bin.x Laplace.o $(OBJ_FILES) ${PETSC_KSP_LIB}
    ${RM} $(OBJ_FILES)

   Matt


> Otherwise there were some error messages related to header files.
>
>
> Thanks again for your help.
>
> Charles
>
> --
What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100324/2b520c2f/attachment.htm>


More information about the petsc-users mailing list