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

I am getting the following error in my program:
error D8016: '/ZI' and '/clr' command-line options are incompatible
This happens when I put the following lines and enable common runtime in configuration->General (If I dont enable it then the error will come at using system and System::Drawing )
#using <system.drawing.dll>
using namespace System;
using namespace System::Drawing;
Actually I will be using some windows library in my code that requires the above dll.
How to solve this issue?
#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;
}

In visual studio to turn off /ZI:
Open the project's Property Pages dialog box.
Click the C/C++ folder.
Click the General property page.
Modify the Debug Information Format property - set it to "None"

Upgrading VS will help. Minimum version: 16.11.11

In addition to what the Answer by PGP suggests, consider also changing C/C++ -> Optimization -> Optimization to Disabled (/Od).
Having it as Maximum Optimization (Favor Speed) (/O2) might give you problems when compiling for debug.
-O2 it's a certain level of compile-time optimisation. Google about what it does

In VS2017:
\ZI is set by C/C++>General>Debug Information Format = Program Database for Edit and Continue
\GL is set by C/C++>Optimization>Whole Program Optimization = Yes
I copied a configuration that I wanted to use as debug config and ran into that issue.

Related

In Codelite C++, when I try to declare a vector and initialize it at the same time, I get an error, although it works in Xcode for some reason

When I try to declare a c++ vector, and initialize it at the same time, I get an error. This only happens to me in codelite - the same exact code works in xcode.
#include <iostream>
#include <vector>
using namespace std;
int main(){
vector <int> myvec {32, 234, 25, 235};
cout<<myvec[1];
return 0;
}
The error is "expected ';' at end of declarion." Then, it shows an arrow pointing in between "myvec" and "{32,234....};", and says to put a ';' there. I know this sounds a little unclear - I can provide a screenshot if necessary.
Thanks for the help.

Boost socket send_to() problems

We have a project that uses a wrapper for Boost socket. I'm trying to add a wrapper for the sent_to() command, but can't get it to compile. We're using C++11.
In the header file, this:
template<typename ConstBufferSequence>
std::size_t send_to(
const ConstBufferSequence & buffers,
const endpoint_type & destination, // error
socket_base::message_flags flags, // error
boost::system::error_code & ec);
generates two errors. They are:
"Type 'endpoint_type' could not be resolved", and
"Type 'socket_base::message_flags' could not be resolved
I've included the requisite header file, and even a more direct one:
#include <boost/asio.hpp>
#include <boost/asio/basic_datagram_socket.hpp>
Neither resolve the issues. I'm sure there is some template black magic that needs to be done here, but I'm at a loss as to what it is. Can anyone give me a pointer as to what's going wrong here?

same code doesn't work on my own project (strcpy) in visual studio 2017

I'm working on some exercises for school.
The projects i have from my teacher work without any errors.
When i copy the code to a new project made on my computer, it shows this error:
Compiler Warning (level 3) C4996
I looked at both compiler settings and made them equal, this didn't work.
So i tried to make a project property file from my teachers project and insert it into my own project. Also this doesn't work.
Can somebody help me solving this issue?
This is the code:
#include <stdio.h>
#include <string.h>
int main(void)
{
char s1[32];
char s2[32];
strcpy(s1, "abc def.");
strcpy(s2, "ghi_x");
printf("s1=\"%s\" en s2=\"%s\"\n", s1, s2);
printf("s1 bevat %d symbolen en s2 bevat %d symbolen\n", strlen(s1), strlen(s2));
printf("De functie strcmp(s1,s2) geeft %d als functiewaarde\n", strcmp(s1, s2));
getchar();
return 0;
}
The Error I get is
Severity Code Description Project File Line Suppression State Error C4996 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details
A quick Google search shows that "Compiler Warning (level 3) C4996" means you're using deprecated functions. The most likely culprits are your str* functions since they are generally unsafe. Switch to using their strn* counterparts (e.g. strncpy).

display result of max() function with imshow in opencv

I have 2 Mat of 1 image with a little differences in some pixels. I want to find max for each pixel and show them. I wrote this code in Visual C++ 2010 (Console):
Mat dst;
max(result0, result1, dst);
imshow("dst", dst);
and the dst image was displayed perfectly, but when I copied this code in windows form I received this error: "error C2440: '?' : cannot convert from 'cv::MatExpr' to 'bool'" so I changed the code to this:
Mat dst;
max(&result0, &result1, &dst);
imshow("dst", dst);
but in run time this error was appeared:
"An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in OpenCVProject.exe
Additional information: External component has thrown an exception."
please help me to display the image.
thanks in advance
I also met this problem.And I find it is the minwindef.h that result in this problem.so you can add this:
#undef max
#undef min
below in the header files(#include<...>),and then you can use cv::max successfully.
I think there is namespaces conflict.
Try specify namespace as below:
cv::max
As suggested by dekai adding the below but after the using namespace headers worked for me
#undef max
#undef min

Get local path from network path

I have a funny situation. I am sitting on a computer on which there is a shared folder, say, "My_Folder". So, I can access it using the address "\My_Box\My_Folder".
Now, if I write a small tool in C#, I can convert the "\My_Box\My_Folder" to "C:\My_Folder" which is its physically location.
The funny thing is that I don't know how to find the physically location of "My_Box\My_Folder" without my program ... And it's actually one of my friend's problem.
So if anyone knows how to find the local path from a network path with some simple basic Windows commands/operations (either Winxp, 2000, vista, 7, ...), please let me know.
Thanks,
Pete.
If all you need is a command line tool that will provide this information then you can simply use the net share command that’s built into Windows.
If you need to do it programmatically you can use the NetShareGetInfo function. The following example shows how to use it to query the path for \\localhost\share in C++.
#include <windows.h>
#include <lm.h>
#pragma comment (lib, "netapi32.lib")
#include <iostream>
using namespace std;
int main()
{
BYTE * buffer = nullptr;
auto error = NetShareGetInfo(nullptr, // local computer
L"share",
2, // level
&buffer);
if (ERROR_SUCCESS == error)
{
auto info = reinterpret_cast<SHARE_INFO_2 *>(buffer);
wcout << info->shi2_path << endl;
}
if (buffer)
{
NetApiBufferFree(buffer);
}
}
I would wrap the buffer in a class and call NetApiBufferFree from its destructor but that’s up to you.

Resources