现在的位置: 首页 > 综合 > 正文

libtiff+opencv2.3.1+vs 2005 编译tiff出错

2013年05月29日 ⁄ 综合 ⁄ 共 2436字 ⁄ 字号 评论关闭

目中用到tiff库编译好之后结果报错如下:

>d:\opencv\build\my\install\include\opencv2\features2d\features2d.hpp(744) : error C2143: syntax error : missing '}' before 'constant'
1>d:\opencv\build\my\install\include\opencv2\features2d\features2d.hpp(744) : error C2059: syntax error : 'constant'
1>d:\opencv\build\my\install\include\opencv2\features2d\features2d.hpp(748) : error C2143: syntax error : missing ';' before '}'
1>d:\opencv\build\my\install\include\opencv2\features2d\features2d.hpp(748) : error C2238: unexpected token(s) preceding ';'
1>d:\opencv\build\my\install\include\opencv2\features2d\features2d.hpp(750) : error C2059: syntax error : 'protected'
1>d:\opencv\build\my\install\include\opencv2\features2d\features2d.hpp(753) : error C2575: 'prepare' : only member functions and bases can be virtual
1>d:\opencv\build\my\install\include\opencv2\features2d\features2d.hpp(754) : error C2575: 'finalize' : only member functions and bases can be virtual
1>d:\opencv\build\my\install\include\opencv2\features2d\features2d.hpp(755) : error C2270: 'getLeaf' : modifiers not allowed on nonmember functions
1>d:\opencv\build\my\install\include\opencv2\features2d\features2d.hpp(765) : error C2065: 'Feature' : undeclared identifier
1>d:\opencv\build\my\install\include\opencv2\features2d\features2d.hpp(765) : error C2133: 'cv::features' : unknown size
1>d:\opencv\build\my\install\include\opencv2\features2d\features2d.hpp(765) : error C2512: 'std::vector' : no appropriate default constructor available
1>d:\opencv\build\my\install\include\opencv2\features2d\features2d.hpp(807) : error C2061: syntax error : identifier 'RNG'
1>d:\opencv\build\my\install\include\opencv2\features2d\features2d.hpp(809) : error C2061: syntax error : identifier 'RNG'
1>d:\opencv\build\my\install\include\opencv2\features2d\features2d.hpp(811) : error C2535: 'void RandomizedTree::train(const std::vector<_Ty> &)' : member function already defined or declared

以上是部分错误。

高了一个下午才发现错误原因,不是编译错误,vs对头文件的处理不够智能:

由于项目庞大而且,用到opencv2,3,1和tiff文件,我编写了一个简单的测试程序,新建一个win32后台控制程序。头文件书写如下:

#include "stdafx.h"

#include <tiffio.h>
#include <tiff.h>
#include <tiffvers.h>
#pragma comment(lib,"libtiff.lib")
#include <opencv2/opencv.hpp>
using namespace cv;

 

编译之后包上面错误。但是更换顺序后:

#include "stdafx.h"
#include <opencv2/opencv.hpp>
using namespace cv;


#include <tiffio.h>
#include <tiff.h>
#include <tiffvers.h>
#pragma comment(lib,"libtiff.lib")

编译成功!一点心得望能给大家以帮助

 

附带:如何编译libtiff库,这个网上有很多,要用vs200自带工具编译,而不是直接运行-》cmd。然后跳到目录下编译

我这个是直接考的opencv1.0带的lib库。使用时注意添加库文件路径和头文件路径;如下:

C:\Program Files\OpenCV\otherlibs\_graphics\lib

C:\Program Files\OpenCV\otherlibs\_graphics\include

 

抱歉!评论已关闭.