t0tott 2019-10-22 16:46 采纳率: 50%
浏览 710
已采纳

导入*.cpp文件后,编译出现错误error LNK2005

seg.cpp的代码功能是预处理图片/检测图片
现在Cpig.cpp中加入include < seg.cpp >
出现如下错误:

1>------ 已启动全部重新生成: 项目: AnimalsFatMeasure, 配置: Release x64 ------
1>stdafx.cpp
1>AnimalsFatMeasure.cpp
1>AnimalsFatMeasureDlg.cpp
1>Cpig.cpp
1>INFOR.cpp
1>seg.cpp
1>seg.obj : error LNK2005: "class cv::Mat g_srcImage" (?g_srcImage@@3VMat@cv@@A) 已经在 Cpig.obj 中定义
1>seg.obj : error LNK2005: "class cv::Mat g_grayImage" (?g_grayImage@@3VMat@cv@@A) 已经在 Cpig.obj 中定义
1>seg.obj : error LNK2005: "class cv::Mat out_therImage" (?out_therImage@@3VMat@cv@@A) 已经在 Cpig.obj 中定义
1>seg.obj : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > saveImage" (?saveImage@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A) 已经在 Cpig.obj 中定义
1>seg.obj : error LNK2005: "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > file_save" (?file_save@@3V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A) 已经在 Cpig.obj 中定义
1>Cpig.obj : error LNK2005: "float __cdecl Zfhanliang(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?Zfhanliang@@YAMV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 已经在 Cpig.obj 中定义
1>Cpig.obj : error LNK2005: "bool __cdecl Jh12(int,int)" (?Jh12@@YA_NHH@Z) 已经在 Cpig.obj 中定义

具体代码如下
seg.cpp

#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>
//#include<squares.cpp>

using namespace cv;
using namespace std;

Mat g_srcImage, g_grayImage, out_therImage;
string saveImage = "preidentify/save";
string file_save = "middleidentify/";

Cpig.cpp代码如下

#include "Resource.h"
#include "stdafx.h"
#include "AnimalsFatMeasure.h"
#include "Cpig.h"
#include "afxdialogex.h"
#include "INFOR.h"
#include <opencv2/opencv.hpp>
#include "seg.cpp"
  • 写回答

1条回答 默认 最新

  • 泡视界 2019-10-22 17:08
    关注

    朋友,.cpp可不是用来include的,你需要整理出一个seg.h来,然后引用这个.h

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)