[petsc-users] compiling petsc.h and cusp's headers

Shiyuan gshy2014 at gmail.com
Tue Oct 4 14:07:40 CDT 2011


Hi,
   I cannot compiling a source file with petsc.h and cusp headers like the
following:

#include"petsc.h"
#include<iostream>
#include "cusp/csr_matrix.h"
#include <cusp/krylov/cg.h>
int main(void){
    std::cout<<"Hello World!"<<std::endl;
    return 0;
}

I use the following  to compile it:

nvcc  -m64 -O -arch=sm_13  -c --compiler-options="-Wall -Wwrite-strings
-Wno-strict-aliasing -Wno-unknown-pragmas -O
-I/home/guest/sgu1/softwares/petsc-dev/include
-I/home/guest/sgu1/softwares/petsc-dev/helena-cxx-nompi-os64-release/include
-I/usr/local/cuda/include -I/home/guest/sgu1/softwares/cusp-library/
-I/home/guest/sgu1/softwares/thrust/
-I/home/guest/sgu1/softwares/petsc-dev/include/mpiuni  -DCUDA=1
-I/home/guest/sgu1/softwares/slepc-dev
-I/home/guest/sgu1/softwares/slepc-dev/helena-cxx-nompi-os64-release/include
-I/home/guest/sgu1/softwares/slepc-dev/include
-I/home/guest/sgu1/softwares/ImageMagick-6.7.2/include/ImageMagick
-D__INSDIR__= -I/home/guest/sgu1/softwares/slepc-dev
-I/home/guest/sgu1/softwares/slepc-dev/helena-cxx-nompi-os64-release/include
-I/home/guest/sgu1/softwares/slepc-dev/include" MyKspTmp4.cu -o MyKspTmp4.o

and it gives me error:
/usr/local/cuda/include/thrust/detail/device/cuda/detail/b40c/vector_types.h(37):
error: expected an identifier

I think I did not do it in a correct way. I took a a look at some of petsc's
.cu files, they usually include a  long list of headers. Can petsc.h
directly included in a source code with cusp headers? What's the correct way
to do it?  Does the makefile system in petsc provide the command or flags to
do that? How can I obtain those flags?

And after I compile it and obtain .o files, can I use g++ to link the .o
files with petcs libs and other .o files as usual, i.e.,
    g++ -o $(BIN_DIR)/$@ $(CPPFLAGS) $@.s $(objects) $(PETSC_LIB) $(OTHERS)
or I need to do some extra steps and some specific linking flags to do that?
Thanks.

Shiyuan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20111004/385b2f14/attachment.htm>


More information about the petsc-users mailing list