[已解决][omp.h]ompparticles.cpp:29:17: fatal error: omp.h: No such file or directory

TheBooksofShaders ShaderToy
OpenGL Tutorial
回复
头像
paktc
出类拔萃
出类拔萃
帖子: 65
注册时间: 2016年07月21日 20:34
联系:

[已解决][omp.h]ompparticles.cpp:29:17: fatal error: omp.h: No such file or directory

帖子 paktc »

编译环境是 Win7 64位
终端默认gcc位于 C:\MinGW\bin
D盘有 TDM-GCC-64 和 TDM-GCC-32
g++ -o ompparticles ompparticles.cpp -ID:/Lib/glfw-3.1.1/include -ID:/sb7code- master/include -LD:/Lib/glfw-3.1.1/lib -LD:/temp/sb7code-master/lib -lsb7 -lglfw 3 -lopengl32 -lglu32 -lgdi32 ompparticles.cpp:29:17: fatal error: omp.h: No such file or directory #include <omp.h> ^ compilation terminated. MAKE: *** [Makefile:10: AIN] Error 1
编译 OpenGL SuperBible 7th 示例代码,提示 找不到omp.h,原因是安装的MinGW默认不带omp.h库

临时办法:
用everything搜索到 D:\TDM-GCC-64\lib\gcc\mingw32\4.8.1\include\omp.h
复制到当前目录,编译指令添加 -I. (不是 -I./)

编译提示
g++ -o ompparticles ompparticles.cpp -ID:/Lib/glfw-3.1.1/include -ID:/sb7code- master/include -I. -LD:/Lib/glfw-3.1.1/lib -LD:/temp/sb7code-master/lib -lsb7 -l glfw3 -lopengl32 -lglu32 -lgdi32 C:\Users\userx\AppData\Local\Temp\cckSB68q.o:ompparticles.cpp:(.text+0x30f): un defined reference to `omp_get_max_threads' C:\Users\userx\AppData\Local\Temp\cckSB68q.o:ompparticles.cpp:(.text+0x31c): un defined reference to `omp_set_num_threads' collect2.exe: error: ld returned 1 exit status MAKE: *** [Makefile:10: AIN] Error 1
通过 everything 找到 对应的库: D:\TDM-GCC-64\lib\gcc\x86_64-w64-mingw32\4.8.1\libgomp.a
复制到当前目录,gcc参数中添加 -L.

再次编译,提示
In file included from ompparticles.cpp:26:0: D:/temp/sb7code-master/include/sb7.h:37:29: error: declaration of C function 'vo id sleep(DWORD)' conflicts with #define Sleep(t) sleep(t) ^ In file included from D:/temp/sb7code-master/include/sb7.h:36:0, from ompparticles.cpp:26: d:\tdm-gcc-64\x86_64-w64-mingw32\include\unistd.h:34:22: error: previous declara tion 'unsigned int sleep(unsigned int)' here unsigned int __cdecl sleep (unsigned int); ^ MAKE: *** [Makefile:10: AIN] Error 1
打开 sb7.h ,找到 #define Sleep(t) sleep(t) 暂时注释掉,编译通过。

需要注意的是,TDM-GCC 在解压安装的时候,虽然带有omp.h,但是默认不包含openmp/gomp的相关库,需要在安装时手动选择
openmp.png
(19.25 KiB) 已下载 887 次
回复

在线用户

正浏览此版面之用户: 没有注册用户 和 1 访客