I have looked everywhere (on these forums and elsewhere) but can't find a solution to my problem.
I have the following code:
1 2 3 4 5 6 7 8 9 10 11 12
int _tmain(int argc, _TCHAR *argv)
// if no arguments are given, print a message and exit
if(argc < 2)
printf("Please provide a path to the input images.");
// put the input_path parameter in a string variable.
string in_path = argv; // argv is the call to this program.
There is some more obviously after getting the in_path, but this is where it goes awry.
When I do a debug build, my in_path is set. But, when I do a release build, I get a <Bad Ptr>!
I have checked the debug call and the debug call for the deployment build also adds the correct parameter. I don't understand why this is only happening with my release build. I have compared the two build configurations and cannot find any relevant differences, other than the obvious because of optimisations.
Character set is "Use Multi-Byte Character Set" for both configurations.
Okay, thanks everyone for your help, but it turns out that I was on a false trail here ...
The call to OpenCV's cv::imread seems to be buggy in a deployment build. I pass it the path to the image and it breaks. So I started debugging the deployment build and my debugger says the string is a <Bad Ptr>.
Turns out, that's just because you can't properly debug optimised code (hence the debug build, I guess).
Further investigation (using printf to see the string through code, rather than the debugger) showed that the string was correct. It was the call to imread that has problems, accessing invalid memory addresses.
I have posted this problem on the OpenCV forums now.
Sorry about this, seems I still have a lot to learn about C++ ...