这个鬼问题折磨死我了,请大虾帮助!identifier "omp_get_num_threads" is undefined

江南一风 2010-05-11 12:32:15
加精
简单程序:
#include <omp.h>
int main(int argc, char *argv[]) {
#pragma omp parallel num_threads(8)
printf("Hello, World!, ThreadId=%d\n", omp_get_num_threads());

return 0;
}

问题:
>------ 已启动生成: 项目: hello1, 配置: Debug Win32 ------
1>Compiling with Intel(R) C++ Compiler 11.1.071 [IA-32]... (Intel C++ Environment)
1>hello1.cpp
1>Warning #673: the initial sequence of preprocessing directives is not compatible with those of precompiled header file "Debug\hello1.pchi"
1>
1>.\hello1.cpp(4): error: identifier "omp_get_num_threads" is undefined
1> printf("Hello, World!, ThreadId=%d\n", omp_get_num_threads());
1> ^
1>
1>compilation aborted for .\hello1.cpp (code 2)
1>Build log was saved at "file://D:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\hello1\hello1\Debug\BuildLog.htm"
1>hello1 - 1 error(s), 0 warning(s)
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========

对omp的库函数调用似乎没起到作用。请高手帮我解决这个入门级问题,不胜感激!!!

首先,我开启/Qopenmp选项了,也用intel编译器了。
真不知道什么问题,跪求解决方案!
...全文
3635 95 打赏 收藏 转发到动态 举报
写回复
用AI写文章
95 条回复
切换为时间正序
请发表友善的回复…
发表回复
flowerjack 2010-05-16
  • 打赏
  • 举报
回复
江南一风 2010-05-16
  • 打赏
  • 举报
回复
[Quote=引用 95 楼 lxadccs 的回复:]
我只知道omp.h文件没加进来,你可以找一下omp.h这个文件在哪!或者引入的库文件不对
[/Quote]

跟预编译有关
JohnYC1 2010-05-15
  • 打赏
  • 举报
回复




di、、的确看不懂。
江南一风 2010-05-15
  • 打赏
  • 举报
回复 1
谢谢各位,分已散出,虽然问题没有得到满意答案,但是有提示的我都给分了。
江南一风 2010-05-15
  • 打赏
  • 举报
回复 1
已解决。加上头文件stdafx.h就可以了,没注意细节,没想到费了那么大劲儿结果就这么简单解决了,大家可能都没有真正的去编译试试看吧,呵呵。不过还是感谢一些热心网友的提示。
AnGe_R 2010-05-15
  • 打赏
  • 举报
回复
受教了
xcnxcn 2010-05-15
  • 打赏
  • 举报
回复 1
好题并且有始有终。
hlm1988 2010-05-15
  • 打赏
  • 举报
回复
嗯,可惜我现在没有时间花在这题上了。
lxadccs 2010-05-15
  • 打赏
  • 举报
回复
我只知道omp.h文件没加进来,你可以找一下omp.h这个文件在哪!或者引入的库文件不对
jiseed 2010-05-14
  • 打赏
  • 举报
回复
不知道诶~~
zyzlshaa 2010-05-14
  • 打赏
  • 举报
回复
请相信,会有牛人帮你解决的
老子不容易 2010-05-14
  • 打赏
  • 举报
回复
我也遇到此问题 等待。。。
jackylvm 2010-05-14
  • 打赏
  • 举报
回复
打开项目配置 tools-〉options -〉directories
分别添加include,lib等的ia32的路径

在project中 打开 project settings
在link选项下 object/library modules的lib中 添加 mkl_c.lib libguide.lib

你出现的错误应该是没有加libguide.lib

注意:
c/c++选项的project options中添加 /Qopenmp 才可以使icc支持openmp,
可以自动添加libguide.lib
的连接

具体配置mkl的使用在icc的html帮助
Getting Started Guide for Intel® Math Kernel Library 9.0
for Windows* 有说明
xiaxia8872 2010-05-14
  • 打赏
  • 举报
回复
真有难度啊,爱莫能助。。。
DefineLove 2010-05-14
  • 打赏
  • 举报
回复
顶2月小黄花..
zhugeliuyun01 2010-05-14
  • 打赏
  • 举报
回复
注意一些细节问题,好好检查一下
szlq9 2010-05-14
  • 打赏
  • 举报
回复
没看明白
mingyunfiy 2010-05-14
  • 打赏
  • 举报
回复
没看懂。。
landuodejian 2010-05-14
  • 打赏
  • 举报
回复
看不懂呀
kock 2010-05-14
  • 打赏
  • 举报
回复
看下头文件里这个函数是否有条件编译
加载更多回复(75)

566

社区成员

发帖
与我相关
我的任务
社区描述
英特尔® 边缘计算,聚焦于边缘计算、AI、IoT等领域,为开发者提供丰富的开发资源、创新技术、解决方案与行业活动。
社区管理员
  • 英特尔技术社区
  • shere_lin
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧