22

我的程序中出现以下错误:

  error D8016: '/ZI' and '/clr' command-line options are incompatible

当我输入以下行并在 configuration->General 中启用 common runtime 时会发生这种情况(如果我不启用它,那么使用 system 和 System::Drawing 时会出现错误)

#using <system.drawing.dll>
using namespace System;
using namespace System::Drawing;

实际上,我将在我的代码中使用一些需要上述 dll 的 windows 库。

如何解决这个问题?

#include "opencv2/highgui/highgui.hpp"
#include <opencv2/imgproc/imgproc_c.h>
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
#include <ctype.h>
#using <system.drawing.dll>
using namespace System;
using namespace System::Drawing;
using namespace std;

int main( int argc, char** argv )
{
IplImage *source = cvLoadImage( "Image.bmp");
// Here we retrieve a percentage value to a integer
int percent =20;
// declare a destination IplImage object with correct size, depth and channels
  IplImage *destination = cvCreateImage
( cvSize((int)((source->width*percent)/100) , (int)((source->height*percent)/100) ),
                                 source->depth, source->nChannels );
//use cvResize to resize source to a destination image
cvResize(source, destination);
// save image with a name supplied with a second argument
   cvShowImage("new:",destination);
  cvWaitKey(0);
 return 0;
 }
4

3 回答 3

29

在视觉工作室中关闭/ZI

  1. 打开项目的属性页对话框。
  2. 单击 C/C++ 文件夹。
  3. 单击常规属性页。
  4. 修改调试信息格式属性 - 将其设置为“无”
于 2014-07-24T03:05:04.023 回答
1

除了 PGP 的答案建议之外,还考虑更改C/C++ -> Optimization -> OptimizationDisabled (/Od)

将其设置为最大优化(优先速度)(/O2)可能会在编译调试时给您带来问题。

-O2 这是一定程度的编译时优化。谷歌关于它的作用

于 2019-01-10T08:16:00.483 回答
1

在 VS2017 中:

  • \ZI 由 C/C++>General>Debug Information Format = Program Database for Edit and Continue 设置
  • \GL 由 C/C++>Optimization>Whole Program Optimization = Yes 设置

我复制了一个我想用作调试配置的配置并遇到了这个问题。

于 2020-10-01T18:39:47.040 回答