pearu / f2py

Automatically exported from code.google.com/p/f2py
Other
54 stars 37 forks source link

"ImportError: DLL load failed: %1 is not a valid Win32 application" with gnu95 #29

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello,

I am able to generate, but not to use the DLLs generated by f2py, in Fortran 90.

Here is my system:
- Windows Vista Business 64 bits
- Python 2.6.5
- numpy 1.5.1rc1
- scipy 0.8.0
- MinGW + gfortran

So to begin with, I wrote a hello.f Fortran file (http://www.scipy.org/F2py). 
Then I compiled it into a python module using the following command:

f2py.py -c --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71 -m hello hello.f

Up to here, everything's alright. However, when I try "import hello" from 
Python, then I get the following error:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
ImportError: DLL load failed: %1 is not a valid Win32 application

On the other hand, everything works fine if I use the gnu compiler (not gnu95) 
without the -lmsvcr71 option:

f2py.py -c --fcompiler=gnu --compiler=mingw32 -m hello hello.f

The problem is that I need to wrap plenty of Fortran 90 code, not Fortran 77...

Help please!!

Thanks in advance

Bruno

Original issue reported on code.google.com by brunodec...@gmail.com on 21 Oct 2010 at 5:36

GoogleCodeExporter commented 8 years ago
Actually I think the problem comes from gfortran itself... Windows won't run 
any program built with gfortran.

Original comment by brunodec...@gmail.com on 21 Oct 2010 at 6:09

GoogleCodeExporter commented 8 years ago
Googling around shows that this error message is related to mixing 32 and 64 
bit codes.
Check if there are 32 and 64 bit differences in python, g77, and gfortran 
programs.
For instance, if you are using 32 bit python then you must also use 32 bit 
gfortran.
If you need 64 bit, then both python and gfortran must be 64 bit programs.

If this information is not helpful then try also f2py-users mailing list.

Original comment by pearu.peterson on 21 Oct 2010 at 6:15

GoogleCodeExporter commented 8 years ago
Perhaps you have 32 bit gfortran then.

Original comment by pearu.peterson on 21 Oct 2010 at 6:17

GoogleCodeExporter commented 8 years ago
Thanks, problem solved!!

As you said, I think that my installations of MinGW and gfortran were not 
consistent (one 32 bit, the other 64 bit, or maybe versions inconsistency). So 
I uninstalled and reinstalled them, and everything works fine -- including f2py 
(which was not the culprit, anyway)!

thanks again

Original comment by brunodec...@gmail.com on 21 Oct 2010 at 8:14

GoogleCodeExporter commented 8 years ago

Original comment by pearu.peterson on 22 Oct 2010 at 8:17