1

我需要在 Python 中包装一个 Fortran 库,并且它需要是 32 位的,因为我使用的是 32 位 EPD。为此,我使用了从 fink 安装的 EPD 和 gcc 4.8 附带的 f2py。我发出以下命令:

f2py -c -m libplot3d --fcompiler=gnu95 plot3d.f90

输出在底部。请注意“文件是为 i386 构建的,它不是被链接的体系结构 (x86_64)”最后的警告。那么我做错了什么,我该如何解决这个问题?

f2py -c -m libplot3d --fcompiler=gnu95 plot3d.f90
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "libplot3d" sources
f2py options: []
f2py:> /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/libplot3dmodule.c
creating /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo
creating /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7
Reading fortran codes...
    Reading file 'plot3d.f90' (format:free)
Post-processing...
    Block: libplot3d
            Block: open_file
            Block: close_file
            Block: read_nblk
            Block: read_header
            Block: read_param
            Block: read_one_block
            Block: write_nblk
            Block: write_header
            Block: write_param
            Block: write_one_block
Post-processing (stage 2)...
Building modules...
    Building module "libplot3d"...
        Constructing wrapper function "open_file"...
          open_file(file_name,endian)
        Constructing wrapper function "close_file"...
          close_file()
        Constructing wrapper function "read_nblk"...
          nblk = read_nblk()
        Creating wrapper for Fortran subroutine "read_header"("read_header")...
        Constructing wrapper function "read_header"...
          read_header(jkmmax,nblk)
        Creating wrapper for Fortran subroutine "read_param"("read_param")...
        Constructing wrapper function "read_param"...
          read_param(jmax,p)
        Creating wrapper for Fortran subroutine "read_one_block"("read_one_block")...
        Constructing wrapper function "read_one_block"...
          read_one_block(jkmmax,ndi,b)
        Constructing wrapper function "write_nblk"...
          write_nblk(nblk)
        Creating wrapper for Fortran subroutine "write_header"("write_header")...
        Constructing wrapper function "write_header"...
          write_header(jkmmax,nblk)
        Creating wrapper for Fortran subroutine "write_param"("write_param")...
        Constructing wrapper function "write_param"...
          write_param(jmax,p)
        Creating wrapper for Fortran subroutine "write_one_block"("write_one_block")...
        Constructing wrapper function "write_one_block"...
          write_one_block(jkmmax,ndi,b)
    Wrote C/API module "libplot3d" to file "/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/libplot3dmodule.c"
    Fortran 77 wrappers are saved to "/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/libplot3d-f2pywrappers.f"
  adding '/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/fortranobject.c' to sources.
  adding '/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7' to include_dirs.
copying /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.c -> /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7
copying /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.h -> /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7
  adding '/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/libplot3d-f2pywrappers.f' to sources.
build_src: building npy-pkg config files
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
customize Gnu95FCompiler
Found executable /sw/bin/gfortran
customize Gnu95FCompiler using build_ext
building 'libplot3d' extension
compiling C sources
C compiler: gcc -fno-strict-aliasing -fno-common -dynamic -arch i386 -DNDEBUG -g -O3 -arch i386

creating /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/var
creating /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/var/folders
creating /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/var/folders/bv
creating /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn
creating /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T
creating /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo
creating /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7
compile options: '-I/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7 -I/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/core/include -I/Library/Frameworks/Python.framework/Versions/7.3/include/python2.7 -c'
gcc: /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/fortranobject.c
In file included from /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1728,
                 from /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17,
                 from /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:15,
                 from /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/fortranobject.h:13,
                 from /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/fortranobject.c:2:
/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/core/include/numpy/npy_deprecated_api.h:11:2: warning: #warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
gcc: /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/libplot3dmodule.c
In file included from /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1728,
                 from /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:17,
                 from /Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:15,
                 from /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/fortranobject.h:13,
                 from /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/libplot3dmodule.c:18:
/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/core/include/numpy/npy_deprecated_api.h:11:2: warning: #warning "Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"
compiling Fortran sources
Fortran f77 compiler: /sw/bin/gfortran -Wall -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran f90 compiler: /sw/bin/gfortran -Wall -fno-second-underscore -fPIC -O3 -funroll-loops
Fortran fix compiler: /sw/bin/gfortran -Wall -ffixed-form -fno-second-underscore -Wall -fno-second-underscore -fPIC -O3 -funroll-loops
compile options: '-I/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7 -I/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/numpy/core/include -I/Library/Frameworks/Python.framework/Versions/7.3/include/python2.7 -c'
gfortran:f90: plot3d.f90
gfortran:f77: /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/libplot3d-f2pywrappers.f
/sw/bin/gfortran -Wall -Wall -undefined dynamic_lookup -bundle /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/libplot3dmodule.o /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/fortranobject.o /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/plot3d.o /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/libplot3d-f2pywrappers.o -L/sw/lib/gcc4.8/lib/gcc/x86_64-apple-darwin12.4.0/4.8.1 -lgfortran -o ./libplot3d.so
ld: warning: ld: warning: ignoring file /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/libplot3dmodule.o, file was built for i386 which is not the architecture being linked (x86_64): /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/libplot3dmodule.oignoring file /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/fortranobject.o, file was built for i386 which is not the architecture being linked (x86_64): /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo/src.macosx-10.5-i386-2.7/fortranobject.o

running scons
Removing build directory /var/folders/bv/x7bctfmj1cg0cc79fn073gd80000gn/T/tmpD9L6Fo
4

0 回答 0