smog
smog

Reputation: 51

DLL not recognized on Windows while compiling with MinGW gfortran

I am trying to link some libraries to create an executable using the gfortran implementation in MinGW on Windows. I have the library files available as .dll and .lib, and they are available on the path. When I try to compile my program, I get an error as follows:

libblas.dll: file not recognized: File format not recognized

My input is as follows:

gfortran -O3  -g dependency.o testmain.o -o ../testrun.exe -lblas -llapack

blas and lapack are the libraries I want to link, and they are available as libblas.dll and liblapack.dll on the path. Other libraries seem to be available as *.a or *.dll.a files, but I am not sure how to convert the libraries I want to use into that format.

Why does this happen and is there a way to work around this to create a working executable?

Upvotes: 1

Views: 1027

Answers (2)

Ax Machina
Ax Machina

Reputation: 36

This often happens if you're trying to run a x64 DLL by a x32 process. For example, if you run lua54.dll build for x64 using ming x32 you'll get this same error. Switching to x32 dll should fix it (that or using a x64 process).

Upvotes: 1

smog
smog

Reputation: 51

As pointed out by @jacob in the question comments, the dll version was 64-bit, whereas the compiler (MinGW) defaulted to a 32-bit version.

Upvotes: 1

Related Questions