【问题标题】:error D8016: '/ZI' and '/clr' command-line options are incompatible错误 D8016:“/ZI”和“/clr”命令行选项不兼容
【发布时间】:2012-11-11 12:59:14
【问题描述】:

我的程序出现以下错误:

  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;
 }

【问题讨论】:

  • 所以删除/ZI 选项。这只是调试信息。

标签: winapi visual-c++ opencv


【解决方案1】:

在visual studio中关闭/ZI

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

【讨论】:

  • 我知道这是旧的,但我遇到了同样的问题并尝试了这个解决方案,现在我得到 '/clr' 和 '/Gm' 不兼容...
  • @ethancodes 进入项目属性,在 C/C++ 下,在 Code Generation 下,关闭 Enable Minimal Rebuild。
【解决方案2】:

除了 PGP 的答复建议之外,还考虑将 C/C++ -&gt; Optimization -&gt; Optimization 更改为 禁用 (/Od)

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

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

【讨论】:

    【解决方案3】:

    在 VS2017 中:

    • \ZI 由 C/C++ 设置>General>Debug Information Format = Program Database for Edit and Continue
    • \GL 由 C/C++ 设置>优化>整个程序优化 = 是

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-28
      • 2015-02-04
      • 1970-01-01
      • 2020-07-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多