qq_25268113
ChangEyes
采纳率10.5%
2015-03-09 01:10 阅读 11.9k

大神们帮帮忙,opencv配置编译不成功(要哭了)

win7在vs2010上配置opencv3.0
按网上教程配置好了环境变量以及vs2010

输入opencv的一个小程序:

#include

#include
using namespace cv;
void main()
{
IplImage *src;
src = cvLoadImage("lena.jpg"); //这里将lena.jpg和lena.cpp文件放在同一个文件夹下
cvNamedWindow("lena",CV_WINDOW_AUTOSIZE);
cvShowImage("lena",src);
cvWaitKey(0);
cvDestroyWindow("lena");
cvReleaseImage(&src);
}

编译结果:
1>------ Build started: Project: lena, Configuration: Debug Win32 ------
1>Build started 2015/3/9 9:06:02.
1>InitializeBuildStatus:
1> Touching "Debug\lena.unsuccessfulbuild".
1>ClCompile:
1> lena.cpp
1>d:\opencv\build\include\opencv2\core\mat.hpp(1413): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
1>d:\opencv\build\include\opencv2\core\mat.hpp(1413): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
1>c:\users\apple\desktop\documents\visual studio 2010\projects\lena\lena\lena.cpp(6): error C2065: 'IplImage' : undeclared identifier
1>c:\users\apple\desktop\documents\visual studio 2010\projects\lena\lena\lena.cpp(6): error C2065: 'src' : undeclared identifier
1>c:\users\apple\desktop\documents\visual studio 2010\projects\lena\lena\lena.cpp(7): error C2065: 'src' : undeclared identifier
1>c:\users\apple\desktop\documents\visual studio 2010\projects\lena\lena\lena.cpp(7): error C3861: 'cvLoadImage': identifier not found
1>c:\users\apple\desktop\documents\visual studio 2010\projects\lena\lena\lena.cpp(8): error C2065: 'CV_WINDOW_AUTOSIZE' : undeclared identifier
1>c:\users\apple\desktop\documents\visual studio 2010\projects\lena\lena\lena.cpp(8): error C3861: 'cvNamedWindow': identifier not found
1>c:\users\apple\desktop\documents\visual studio 2010\projects\lena\lena\lena.cpp(9): error C2065: 'src' : undeclared identifier
1>c:\users\apple\desktop\documents\visual studio 2010\projects\lena\lena\lena.cpp(9): error C3861: 'cvShowImage': identifier not found
1>c:\users\apple\desktop\documents\visual studio 2010\projects\lena\lena\lena.cpp(10): error C3861: 'cvWaitKey': identifier not found
1>c:\users\apple\desktop\documents\visual studio 2010\projects\lena\lena\lena.cpp(11): error C3861: 'cvDestroyWindow': identifier not found
1>c:\users\apple\desktop\documents\visual studio 2010\projects\lena\lena\lena.cpp(12): error C2065: 'src' : undeclared identifier
1>c:\users\apple\desktop\documents\visual studio 2010\projects\lena\lena\lena.cpp(12): error C3861: 'cvReleaseImage': identifier not found
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:02.25
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

然后尝试输入:
#include
#include

int main()
{
printf("Hello world!");

return 0;
}

编译也不成功
1>------ Build started: Project: lena, Configuration: Debug Win32 ------
1>Build started 2015/3/9 9:12:16.
1>InitializeBuildStatus:
1> Touching "Debug\lena.unsuccessfulbuild".
1>ClCompile:
1> lena.cpp
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>LINK : fatal error LNK1104: cannot open file 'opencv_calib3d300.lib'
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:03.02
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

为什么啊55555~,版本号也是对的呀,为什么打不开opencv_calib3d300.lib

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

5条回答 默认 最新

  • hsqaihkl 穆林枫 2015-03-09 02:06

    不知道是不是自己落后了,好像2.0.0以后的opencv矩阵都不是 IplImage src;了吧???
    而且听说WIN7是不支持的,试试win8 看看!我也正想装这个。。。。现在我还用2.4.9的,感觉落后了。。。

    点赞 评论 复制链接分享
  • hsqaihkl 穆林枫 2015-03-09 02:16

    这个是我2.4.9上写的希望对你有帮助

    #include "StdAfx.h"
    #include
    #include
    #include
    using namespace std;
    using namespace cv;
    #pragma comment(lib,"opencv_core249.lib")
    #pragma comment(lib,"opencv_highgui249.lib")
    #pragma comment(lib,"opencv_stitching249.lib")

    int main(void)
    {
    string dstFile="E:\MyTestWork\CTest1\resultshan.jpg";//注意很多情况下都是"\"而不是"\",若果"\"不行你就是试试"\"
    Mat img=imread(dstFile);
    namedWindow("Result");
    imshow("Result",img);

    waitKey(0);

    destroyWindow("Result");
    return 0;

    }

    点赞 评论 复制链接分享
  • oyljerry oyljerry 2015-03-09 11:39

    主要是头文件错误,先看那些找不到的定义在opencv的什么头文件中,lib库也要找到它存在的路径和名字,然后添加到工程。

    点赞 评论 复制链接分享
  • xiaojiasheng 小贾生 2015-07-30 05:37

    是不是lib的路径没有添加,或者linker里面lib名字没写?

    点赞 评论 复制链接分享
  • xnninger xnninger 2017-01-31 09:12

    1>c:\users\apple\desktop\documents\visual studio 2010\projects\lena\lena\lena.cpp(8): error C3861: 'cvNamedWindow': identifier not found
    请问您这个错误是怎么解决的??出现这个错误意思是opencv配置失败吗??

    点赞 评论 复制链接分享

相关推荐