无法使OpenMP与CodeBlocks和GFortran一起使用

时间:2013-07-20 18:33:50

标签: gcc openmp codeblocks gfortran

出于某种原因,我无法使OpenMP与CodeBlocks和GFortran一起工​​作。我尝试了另一个IDE(Geany),它运行正常,但CodeBlocks却没有。我必须说我在CodeBlocks中包含了-fopenmp选项。

这是我测试的一个简单代码。

program test
implicit none
integer i

!$OMP PARALLEL DO DEFAULT(PRIVATE)
Do i=1,10
Write(*,*) i
end do
!$OMP END PARALLEL DO

end program test

这是构建日志:

-------------- Build: Debug in TEST (compiler: GNU Fortran Compiler)---------------

gfortran.exe -Jobj\Debug\ -Wall  -g  -fopenmp    -c "C:\Users\tilter\Dropbox\Public\Code\Nova pasta\TEST\main.f95" -o obj\Debug\main.o
gfortran.exe  -o bin\Debug\TEST.exe obj\Debug\main.o    
obj\Debug\main.o: In function `test':
C:/Users/tilter/Dropbox/Public/Code/Nova pasta/TEST/main.f95:5: undefined reference to `GOMP_parallel_start'
C:/Users/tilter/Dropbox/Public/Code/Nova pasta/TEST/main.f95:5: undefined reference to `GOMP_parallel_end'
obj\Debug\main.o:C:/Users/tilter/Dropbox/Public/Code/Nova pasta/TEST/main.f95:6: undefined reference to `GOMP_parallel_start'
obj\Debug\main.o:C:/Users/tilter/Dropbox/Public/Code/Nova pasta/TEST/main.f95:6: undefined reference to `GOMP_parallel_end'
obj\Debug\main.o:C:/Users/tilter/Dropbox/Public/Code/Nova pasta/TEST/main.f95:8: undefined reference to `omp_get_num_threads'
obj\Debug\main.o:C:/Users/tilter/Dropbox/Public/Code/Nova pasta/TEST/main.f95:8: undefined reference to `omp_get_thread_num'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
6 errors, 0 warnings (0 minutes, 0 seconds)

我不知道我在这里缺少什么...

1 个答案:

答案 0 :(得分:0)

我刚刚重启Windows 7,它修复了问题。