我有 Windows 7 操作系统。 我已按照 PETSc web page 的说明进行操作;在 VS 2005 的命令提示符中,我打开了 cygwin 并使用以下命令安装了 PETSc:
./configure --with-cc='win32fe cl' --with-fc=0 --with-mpi=0 --download-f2cblaslapack
我尝试从网页运行以下示例:
cd src/ksp/ksp/examples/tutorials
make ex2
ex2.c是c程序代码。我收到以下错误:
$ make ex2
makefile:18: /conf/variables: No such file or directory
makefile:19: /conf/rules: No such file or directory
makefile:1151: /conf/test: No such file or directory
make: *** No rule to make target `/conf/test'. Stop.
这是什么原因造成的?
(更重要的是) 我该如何修复它?
*编辑:我也可以使用一般性答案,因为目前我什至不知道要 Google 搜索什么,而且我不想只联系 PETSc 支持来解决所有问题。
<小时/>我决定在 Ubuntu 上工作。现在,事情就这样了。安装后我写:
gcc -I$PETSC_DIR/include -L$PETSC_DIR/$PETSC_ARCH/lib -libpetsc ex2
在命令行中。我收到错误消息:
/usr/bin/ld: cannot find -libpetsc ex2: In function
_start': (.text+0x1bc4): multiple definition of
_start' /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o:(.text+0x0): first defined here ex2: In function_fini': (.fini+0x0): multiple definition of
_fini' /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crti.o:(.fini+0x0): first defined here ex2:(.rodata+0x0): multiple definition of_IO_stdin_used' /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o:(.rodata.cst4+0x0): first defined here ex2: In function
__data_start': (.data+0x0): multiple definition of__data_start' /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o:(.data+0x0): first defined here ex2: In function
__data_start': (.data+0x8): multiple definition of__dso_handle' /usr/lib/gcc/x86_64-linux-gnu/4.6/crtbegin.o:(.data+0x0): first defined here ex2: In function
_init': (.init+0x0): multiple definition of `_init' /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crti.o:(.init+0x0): first defined here collect2: ld returned 1 exit status
最佳答案
如 PETSc web page 中所述在遇到问题?部分下,了解与 make
相关的问题您需要设置PETSC_DIR
和PETSC_ARCH
由配置打印。
是什么原因造成的?:
makefile
在src/ksp/ksp/examples/tutorials
目录指PETSC_DIR
包含配置文件,即
include ${PETSC_DIR}/conf/variables
include ${PETSC_DIR}/conf/rules
...
include ${PETSC_DIR}/conf/test
现在当你执行 make
时正如 make ex2
(从错误来看,它表明您尚未设置PETSC_DIR
变量),${PETSC_DIR}
因此是空的make
尝试包括/conf/variables
, /conf/rules
& /conf/test
不存在的文件。
如何修复它?
你必须运行make
正如网站上提到的
make PETSC_DIR=<dir_output_from_configure> PETSC_ARCH=<arch_output_from_configure> ex2
在此之前,您需要正确构建源。为了澄清你在问题./configure ...
中提到的内容不安装 PETSc,仅配置构建源。您需要运行make
。当您运行configure
时如果成功,它将输出配置详细信息,包括 PETSC_DIR
和PETSC_ARCH
。示例输出:
./configure --with-mpi=0
===============================================================================
Configuring PETSc to compile on your system
===============================================================================
TESTING: alternateConfigureLibrary from PETSc.packages.petsc4py(config/PETSc/packages/petsc4py.py:65) Compilers:
...
...
PETSc:
PETSC_ARCH: arch-linux2-c-debug
PETSC_DIR: /XXXX/petsc-3.3-p1
Clanguage: C
Scalar type: real
Precision: double
shared libraries: disabled
dynamic loading: disabled
Memory alignment: 16
xxx=========================================================================xxx
Configure stage complete. Now build PETSc libraries with (cmake build):
make PETSC_DIR=/XXXX/petsc-3.3-p1 PETSC_ARCH=arch-linux2-c-debug all
or (experimental with python):
PETSC_DIR=/XXXX/petsc-3.3-p1 PETSC_ARCH=arch-linux2-c-debug ./config/builder.py
xxx=========================================================================xxx
然后你就运行了make PETSC_DIR=/XXXX/petsc-3.3-p1 PETSC_ARCH=arch-linux2-c-debug all
如 configure
的输出中所述。这将构建库。现在您应该能够构建示例了。 (请注意,这是在 Linux 上运行的,您应该几乎能够在 cygwin 上执行相同的操作)
旁注:似乎没有必要设置PETSC_ARCH
为了构建示例,您应该能够使用 make PETSC_DIR=<dir_output_from_configure> ex2
进行构建
希望这有帮助!
关于c - PETSc 示例不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11331289/