undefined reference to `

I am trying to compile a Fortran 90 file with f2py, to use in a Python module. The file is composed of two subroutines. I can compile the file, using gfortran ljlib3.f90 in the command window, but I get errors when trying to compile the subroutine with f2py.

I am using Python(x,y) on Win 10 (Python 2.7.10) and Mingw-w64 (all properly installed). It's difficult because this is someone else's code from the tutorial, where in my case all works fine until almost the end of the compiling (when comparing with the tutorial).

Here are the subroutines in the file ljlib3.f90:

subroutine EnergyForces(Pos, L, rc, PEnergy, Forces, Dim, NAtom)
implicit none
integer, intent(in) :: Dim, NAtom
real(8), intent(in), dimension(0:NAtom-1, 0:Dim-1) :: Pos
real(8), intent(in) :: L, rc
real(8), intent(out) :: PEnergy
real(8), intent(inout), dimension(0:NAtom-1, 0:Dim-1) :: Forces
!f2py intent(in,out) :: Forces
real(8), dimension(Dim) :: rij, Fij, Posi
real(8) :: d2, id2, id6, id12
real(8) :: rc2, Shift
integer :: i, j
PEnergy = 0.
Forces = 0.
Shift = -4. * (rc**(-12) - rc**(-6))
rc2 = rc * rc
do i = 0, NAtom - 1
    !store Pos(i,:) in a temporary array for faster access in j loop
    Posi = Pos(i,:)
    do j = i + 1, NAtom - 1
        rij = Pos(j,:) - Posi
        rij = rij - L * dnint(rij / L)
        !compute only the squared distance and compare to squared cut
        d2 = sum(rij * rij)
        if (d2 > rc2) then
            cycle
        end if
        id2 = 1. / d2            !inverse squared distance
        id6 = id2 * id2 * id2    !inverse sixth distance
        id12 = id6 * id6         !inverse twelvth distance
        PEnergy = PEnergy + 4. * (id12 - id6) + Shift
        Fij = rij * ((-48. * id12 + 24. * id6) * id2)
        Forces(i,:) = Forces(i,:) + Fij
        Forces(j,:) = Forces(j,:) - Fij
    enddo
enddo
end subroutine

subroutine VVIntegrate(Pos, Vel, Accel, L, CutSq, dt, KEnergy, PEnergy, Dim, 
NAtom)
implicit none
integer, intent(in) :: Dim, NAtom
real(8), intent(in) :: L, CutSq, dt
real(8), intent(inout), dimension(0:NAtom-1, 0:Dim-1) :: Pos, Vel, Accel
!f2py intent(in,out) :: Pos, Vel, Accel
real(8), intent(out) :: KEnergy, PEnergy
external :: EnergyForces
Pos = Pos + dt * Vel + 0.5 * dt*dt * Accel
Vel = Vel + 0.5 * dt * Accel
call EnergyForces(Pos, L, CutSq, PEnergy, Accel, Dim, NAtom)
Vel = Vel + 0.5 * dt * Accel
KEnergy = 0.5 * sum(Vel*Vel)
end subroutine

Notice the !f2py intent(in,out)... directives are also used in subroutines.

After using the f2py command:

f2py -c -m ljlib ljlib3.f90 --fcompiler=gnu95 compiler=mingw32

The following error appears:

C:Program_Filesmingw-w64x86_64-7.2.0-posix-sjlj-rt_v5-
rev1mingw64bingfortran.exe -Wall -g -Wall -g -shared 
c:userspc2012appdatalocaltemptmp_pzjlcReleaseusers 
pc2012appdatalocaltemptmp_pzjlcsrc.win32-2.7ljlibmodule.o 
c:userspc2012appdatalocaltemptmp_pzjlcReleaseusers 
pc2012appdatalocaltemptmp_pzjlcsrc.win32-2.7fortranobject.o 
c:userspc2012appdatalocaltemptmp_pzjlcReleaseljlib3.o -
LC:Program_Filesmingw-w64x86_64-7.2.0-posix-sjlj-rt_v5-
rev1mingw64libgccx86_64-w64-mingw327.2.0 -LC:Python27libs -
LC:Python27PCbuild -lpython27 -lgfortran -o .ljlib.pyd
c:userspc2012appdatalocaltemptmp_pzjlcReleaseusers 
pc2012appdatalocaltemptmp_pzjlcsrc.win32-
2.7ljlibmodule.o:ljlibmodule.c:(.text+0x1a): undefined reference to 
`__imp_PyFloat_Type'
c:userspc2012appdatalocaltemptmp_pzjlcReleaseusers 
pc2012appdatalocaltemptmp_pzjlcsrc.win32-
2.7ljlibmodule.o:ljlibmodule.c:(.text+0x26): undefined reference to 
`__imp_PyType_IsSubtype'
c:userspc2012appdatalocaltemptmp_pzjlcReleaseusers 
pc2012appdatalocaltemptmp_pzjlcsrc.win32-
2.7ljlibmodule.o:ljlibmodule.c:(.text+0x55): undefined reference to 
`__imp_PyNumber_Float'  ...

error: Command "C:Program_Filesmingw-w64x86_64-7.2.0-posix-sjlj-rt_v5-
rev1mingw64bingfortran.exe -Wall -g -Wall -g -shared 
c:userspc2012appdatalocaltemptmp_pzjlcReleaseusers 
pc2012appdatalocaltemptmp_pzjlcsrc.win32-2.7ljlibmodule.o 
c:userspc2012appdatalocaltemptmp_pzjlcReleaseusers 
pc2012appdatalocaltemptmp_pzjlcsrc.win32-2.7fortranobject.o 
c:userspc2012appdatalocaltemptmp_pzjlcReleaseljlib3.o -
LC:Program_Filesmingw-w64x86_64-7.2.0-posix-sjlj-rt_v5-
rev1mingw64libgccx86_64-w64-mingw327.2.0 -LC:Python27libs -
LC:Python27PCbuild -lpython27 -lgfortran -o .ljlib.pyd" failed with exit 
status 1

An error occurs after many undefined reference to ....'`. I guess that this is some PATH issue but I am not sure.

链接地址: http://www.djcxy.com/p/96146.html

上一篇: 强制关闭onClick的ImageButton,不知道为什么

下一篇: 未定义的参考`