编译opencv简单程序会导致与windows sdk冲突

时间:2012-05-25 18:23:57

标签: visual-studio-2010 visual-c++ opencv

这是我第一次使用opencv。我下载了它并设置了visual studio 2010(pro)包含这样的目录:

C:\opencv\build\include\opencv
C:\opencv\build\include

“继承”值为:

$(VCInstallDir)include
$(VCInstallDir)atlmfc\include
$(WindowsSdkDir)include
$(FrameworkSDKDir)\include

但是当我编译时,我得到关于windows sdk的错误...

1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\ws2def.h(212): error C2011: 'sockaddr' : 'struct' type redefinition
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winsock.h(485) : see declaration of 'sockaddr'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\ws2def.h(390): error C2059: syntax error : 'constant'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\ws2def.h(443): error C2143: syntax error : missing ';' before '}'
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\ws2def.h(443): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\ws2def.h(443): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\ws2def.h(524): warning C4005: 'IN_CLASSA' : macro redefinition
1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winsock.h(287) : see previous definition of 'IN_CLASSA'
...

与sdk包含文件存在一些冲突。有谁知道我该如何解决这个问题? 谢谢

1 个答案:

答案 0 :(得分:1)

正在使用winsock2.h并且由于某种原因它与opencv冲突。将其更改为winsock.h