t0tott 2019-10-23 11:11 采纳率: 0%
浏览 914

C++导入*.h头文件后 出现LNK2001无法解析的外部符号 含有opencv库

seg.h 头文件导入至 Cpig.cpp文件后出现如下错误:

1>------ 已启动生成: 项目: AnimalsFatMeasure, 配置: Release x64 ------
1>Cpig.cpp
1>seg.cpp
1>Cpig.obj : error LNK2001: 无法解析的外部符号 "class cv::Mat g_srcImage" (?g_srcImage@@3VMat@cv@@A)
1>Cpig.obj : error LNK2001: 无法解析的外部符号 "class cv::Mat g_grayImage" (?g_grayImage@@3VMat@cv@@A)
1>D:\AnimalsFatMeasure\AnimalsFatMeasure\x64\Release\AnimalsFatMeasure.exe : fatal error LNK1120: 2 个无法解析的外部命令
//seg.h
#ifndef __SEG_H__
#define __SEG_H__

#include"stdafx.h"
#include <iostream>
#include<opencv2\opencv.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<vector>
#include<math.h>
#include<algorithm>
#include<time.h>
#include<io.h>
#include<stdio.h>
#include<string>

using namespace cv;
using namespace std;

extern Mat g_srcImage;
extern Mat g_grayImage;

inline void ImageLoad(string imagefile) {

    Mat ori_image = imread(imagefile, 0);
    Rect rect(100, 100, 540, 400);
    ori_image = ori_image(rect);//截取图像
    threshold(ori_image, ori_image, 1, 255, CV_THRESH_BINARY);//二值化
    //threshold(ori_image, ori_image, g_nThresh, g_nMaxThresh, CV_THRESH_BINARY);//二值化
    //waitKey(0);
    imwrite("binaryimg.jpg", ori_image);

    g_srcImage = imread("binaryimg.jpg", 1);
    if (!g_srcImage.data)
    {
        printf("读取错误,图片不存在");
    }
    //得到原图的灰度图并进行平滑
    //Point point;
    cvtColor(g_srcImage, g_grayImage, COLOR_BGR2GRAY);
    blur(g_grayImage, g_grayImage, Size(3, 3));
    on_ContourChange(0, 0);
}

// Cpig.cpp: 实现文件

#include <opencv2/opencv.hpp>
#include "stdafx.h"
#include "Cpig.h"
#include "afxdialogex.h"
#include "resource.h"
#include <algorithm>
#include <fstream>
#include <string>
#include <windows.h> 
#include <iostream>
#include "INFOR.h"
#include "seg.h"

  • 写回答

2条回答 默认 最新

  • luiio 2019-11-05 14:30
    关注

    1.链接器-输入 里边确认引用了相应的.lib文件吗?
    2.64位release的输出exe的文件下,确认有opencv的dll吗?如果配置的的是环境变量的形式,确认环境变量是不是对的,以及环境变量是否引用了。
    3.还有就是64release,64debug,32debug,32release是否配置错地方了。
    4.opencv的版本是不是64位的。

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!