在Visual Studio 2008中,我试图运行一个我在互联网上找到的基本OpenCV程序。它应该是最简单的程序,同时仍然使用OpenCV。如果需要,我可以发布源代码,但错误似乎与包含文件的内容有关。 我的三个包括:
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
编译时生成的错误是:
c:\users\noah huber-feely\documents\visual studio 2008\projects\opencvtests\opencvtests\targetver.h(10) : error C3409: empty attribute block is not allowed
为stdafx.h生成相同的错误。
网络上没有其他内容似乎已经解决了这个问题,所以我不知所措。如果有人能指出我正确的方向或协助我发现解决方案,那将非常感激。
以下是完整的源代码:
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
int main ( int argc, char* arv[] )
{
IplImage *image = 0;
image = cvLoadImage("C:\Users\Noah Huber-Feely\Desktop\IMG_1484.jpg", 1);
if( image )
{
cvNamedWindow( "Input Image", 1);
cvShowImage( "Input Image", image);
printf( "Press a key to exit\n");
cvWaitKey(0);
cvDestroyWindow( "String" );
}
else
fprintf( stderr, "Error reading image\n" );
return 0;
}
以下是targetver.h的内容:
#pragma once
// The following macros define the minimum required platform. The minimum required platform
// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
// your application. The macros work by enabling all features available on platform versions up to and
// including the version specified.
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
[!if DLL_APP || WIN_APP || SUPPORT_MFC || SUPPORT_ATL]
#ifndef WINVER // Specifies that the minimum required platform is Windows Vista.
#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows.
#endif
[!endif]
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
#endif
[!if DLL_APP || WIN_APP || SUPPORT_MFC || SUPPORT_ATL]
#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0.
#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE.
#endif
[!endif]