gfortran无法使用MinGW找到OpenMP库(omp_lib.mod) [英] gfortran can't find OpenMP library (omp_lib.mod) using MinGW
问题描述
我正在尝试编译包括OpenMP在内的Fortran代码.我从另一个代码复制了OpenMP的用法.它昨天成功构建了一次,然后下次构建时,出现以下错误:
I am trying to compile a Fortran code including OpenMP. I am replicating the use of OpenMP from a different code. It built successfully once yesterday and then the next time I built it I get the following error:
../MAXBRG3D.f90:3:4:
USE OMP_LIB ! USED WITH OMP FUNCTIONS
1
Fatal Error: Can't open module file 'omp_lib.mod' for reading at (1): No such file or directory
compilation terminated.
subdir.mk:329: recipe for target 'MAXBRG3D.o' failed
make: *** [MAXBRG3D.o] Error 1
我对代码所做的唯一更改是在其中注释掉与OpenMP功能无关的几部分代码.此后,我删除了评论,但仍收到相同的错误.我的编译命令如下.
The only changes I made to the code where to comment out a few sections of code unrelated to the OpenMP capabilities. I have since removed the comments but am still getting the same error. My compilation command is as follows.
gfortran -funderscoring -O0 -g -Wall -c -fmessage-length=0 -fopenmp -o "MAXBRG3D.o" "../MAXBRG3D.f90"
我看过以下链接: gfortran可以在MinGW下找不到OpenMP库(omp_lib.mod)当我运行 gfortran -v时,--enable-libgomp
确实显示.
I have seen the following link: gfortran can't find OpenMP library (omp_lib.mod) under MinGW
and when I run gfortran -v, --enable-libgomp
does show up.
>gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe
Target: mingw32
Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --with-gmp=/mingw --with-mpfr=/mingw --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --with-tune=generic --enable-libgomp --disable-libvtv --enable-nls
Thread model: win32
gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
我能够运行以下Fortran小代码.
I was able to run the following little Fortran code.
PROGRAM TEST
INTEGER M
REAL C(3), D(3)
M=3
C(1) = 2
C(2) = 5
C(3) = 10
call A1(M,C,D)
write(*,5)D(3)
5 format(1x,'D3=',G12.5)
END PROGRAM
SUBROUTINE A1(N, A, B)
INTEGER I, N
REAL B(N), A(N)
!$OMP PARALLEL DO !I is private by default
DO I=2,N
B(I) = (A(I) + A(I-1)) / 2.0
ENDDO
!$OMP END PARALLEL DO
END SUBROUTINE A1
我也有libgomp.a,libgomp.dll.a,libgomp.spec(位于MinGW \ lib \ gcc \ mingw32 \ 6.3.0中)和libgomp-1.dll(位于MinGW \ bin中).
Also I do have libgomp.a, libgomp.dll.a, libgomp.spec, (located in MinGW\lib\gcc\mingw32\6.3.0) and libgomp-1.dll (located in MinGW\bin).
推荐答案
我已经解决了这个问题.我注释掉 USE OMP_LIB
行,并刚刚初始化了要使用的功能.
I have solved this problem. I commented out the USE OMP_LIB
line and I just initialized the functions that I wanted to use.
以前,我找到了一个将函数初始化为的示例
Previously I found an example which initialized the functions as
INTEGER FUNCTION OMP_GET_THREAD_NUM()
这不起作用.但是,我发现了另一个示例,该示例将函数初始化为整数.所以
This was not working. However I found a different example which initialized the functions just as integers. So
INTEGER OMP_GET_THREAD_NUM
这似乎已经解决了问题,现在代码正在编译并运行.
This seems to have solved the problem and now the code is compiling and running.
这篇关于gfortran无法使用MinGW找到OpenMP库(omp_lib.mod)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!