在OS X上编译PETSc示例时出错

时间:2017-08-11 21:06:35

标签: c++ macos petsc

这是hello.cpp。我是OS X.我直接从源代码建立了PETSc。

#include <petscvec.h>

int main(int argc,char **argv)
{
 Vec x;
 PetscInitialize(&argc, &argv, NULL, NULL);
 VecCreateSeq(PETSC_COMM_SELF, 100, &x);
 VecSet(x, 1.);
 PetscFinalize();
 return 0;
} 

这是我的makefile

PETSC_BASE_DIR=/Users/buddha/src/petsc
PETSC_LIB_DIR=${PETSC_BASE_DIR}/lib
PETSC_INCLUDE_DIR=${PETSC_BASE_DIR}/include

INCLUDES=$(PETSC_INCLUDE_DIR)
LIBS=$(PETSC_LIB_DIR)

CC=g++
EXEC=oy
ARGS=-Wall -lstdc++
CPP=hellp.cpp
#CPP=oy.cpp

all: hello.cpp
   $(CC) $(ARGS) -I$(INCLUDES) -L$(LIBS) -o $(EXEC) $<

clean:
   rm $(EXEC)

run:
   ./$(EXEC)

哪个收益

make
g++ -Wall -lstdc++ -I/Users/buddha/src/petsc/include 
   -L/Users/buddha/src/petsc/lib -o oy hello.cpp
Undefined symbols for architecture x86_64:
"_PetscFinalize", referenced from:
    _main in hello-924d8b.o
 "_PetscInitialize", referenced from:
  _main in hello-924d8b.o
 "_VecCreateSeq", referenced from:
    _main in hello-924d8b.o
 "_VecSet", referenced from:
    _main in hello-924d8b.o
 "_ompi_mpi_comm_self", referenced from:
    _main in hello-924d8b.o
 ld: symbol(s) not found for architecture x86_64
 clang: error: linker command failed with exit code 1 (use -v to see invocation)
 make: *** [all] Error 1

图书馆正在正确链接。关于这个主题的大部分讨论都说尝试使用我正在做的g ++。

0 个答案:

没有答案