dlib and windows function conflict - c++

I have recently added dlib 19.1 to my project in Visual Studio 2013. I'm able to run compile the library without problem, to run the example and also to create my own console applications and make it work just fine.
But when integrating dlib to my project, I have recently faced the current error:
Error 14 error : identifier "WaitForSingleObject" is undefined
\include\dlib\threads\threads_kernel_1.h 120
There are 50 errors similar to this one, all in threads_kernel_1.h
I'm looking to all project properties and didn't find anything suspicious compare to my example project that include dlib.

identifier "WaitForSingleObject" is defined by including <windows.h> header in your application. this header is included by \include\dlib\threads\threads_kernel_1.h, but something went wrong on your machine
You can try using this function separate from dlib and check if it works in your application first.
Also you can explicitly #include <windows.h> at the top of your cpp file
And do you have any custom "windows.h" file in your application, may be some naming conflict?
Also I can recommend you generating Visual Studion project by CMake and then using it from IDE

Related

SDK Implementation lib/inc/dll

I'm using Microsoft Visual Studio and an SDK to develop an app. The SDK includes the files listed above. I'm coding in C++. I'm not sure what I need to include to be able to use the SDK.
I did the things below and tried building a simple hello world app but I keep getting the error LNK2019: unresolved external symbol_WinMain#16 referenced in function __tmainCRTStartup
What I've Done:
1)Right Click-Properties-Linker-Additional Library Directories-Changed path to where I have the lib folder on my computer.
2)Same but added the Inc folder that came with the SDK to C/C++ Additional Include Directories.
By doing the above I assume I am linking the lib and .h files to the project that came with the SDK. The SDK also came with .dll files which I have done nothing with. You can use a few different languages with the SDK so I'm not sure what I need to use and not use.
However, the header files are not showing up under external dependencies.
I guess I should note that I have tried to run it a couple times before this and am not sure if that could be causing an issue building it.
Thanks.
The error you're seeing has nothing to do with header files or source code. The error is due to you not choosing the correct Visual Studio project.
If you are writing a console program, and you defined a main() function as the entry point, then you should be choosing a Win32 Console Application project from Visual Studio.
The error stems from the program looking for the WinMain function, and that function exists when you choose a Win32 Project. Usually these projects are for building GUI-based Win32 apps.

OpenCV w/ CUDA build fail on Visual Studio 2013 [duplicate]

I'm trying to build OpenCV 2.4.6 on Windows 8 in Visual Studio 2012. Having downloaded the source from https://github.com/Itseez/opencv I generate (leaving the default configuration) using cmake and then load the resulting file ALL_BUILD.vcxproj into Visual Studio 2012. I then try to build it. Several of the modules do indeed build (e.g. core, flann, imgproc, ...) but I am trying to build highgui so that I can use the PDB file for debugging my code (which fails to open a video file). The build errors start with this and many similar errors:
error C2039: 'max' : is not a member of 'std' C:\OpenCV2.4.6\3rdparty\openexr\Imath\ImathMatrixAlgo.cpp 1094 1 IlmImf
One fix for errors like this (e.g. in this answer) is to add #include <algorithm> to the failing files. I tried that on a few files and it seems to work but I'm nervous about locally changing the source for a popular library. It must build on Windows (you can download the binaries, though not the PDB files, from the OpenCV sourceforge site) so I would like to understand how to build it on my machine without changing the source.
Am I missing something out in the configuration step? Is there some path setting etc. missing on my machine? Why am I getting these errors and how should I fix them?
========== EDIT ==========
Looking at the directory path this appears to be a problem with one of the 3rd party dependencies, OpenEXR. Looking on Github it appears to be version 1.7.1 of OpenEXR that is used in OpenCV 2.4.6. The instructions in the OpenCV's Quick Start Installation on Windows state:
In case of the Eigen library it is again a case of download and extract to the D:/OpenCV/dep directory.
Same as above with OpenEXR.
so I downloaded the OpenEXR 1.7.1 source code release and extracted the resulting files putting the directory openexr-1.7.1 into C:\OpenCV2.4.6\dep.
Then I ran cmake and tried to build the resulting Visual Studio solution. Sadly I see the same errors.
I was stumbling on the same issue while compiling OpenEXR. Then I found the solution googling for openexr std::min.
There is an issue opened on OpenCV where it says that, when using VS2013 Preview, you must add the line #include <algorithm> in the file where you're using std::min and std::max.
I put that line into the files where these methods are called and voilĂ ! Compilation succeeded.
You probably need to #define NOMINMAX. Try putting it before any other includes.
If that helps, then put in the you project's preprocessor defines.
There's lots of info about this, just search for NOMINMAX. Here's one post about it.
#include <iostream>
#include <algorithm>
Just include above 2 lines to the cpp file and the compilation error will disappear.

Visual Studio not using additional include directories for KinectBridgeWithOpenCVBasics D2D C++ Sample, but does for other solutions.

I'm working on adding some openCV features to a couple projects that use the Kinect and openGL/freeGLUT. I have downloaded and installed OpenCV using the pre-built libraries and successfully run a simple sample. Now I want to work with the Kinect Bridge with OpenCV Basics sample from the Kinect for Windows Developer Toolkit to get a better idea of how to use OpenCV with the Kinect. I downloaded the sample into my projects folder, opened the solution in visual studio and built it. I got the following errors:
Error 1 error C1083: Cannot open include file:
'opencv2/core/core.hpp': No such file or
directory c:\users\justin\documents\visual studio
2010\projects\kinectbridgewithopencvbasics-d2d\OpenCVHelper.h 17
and
Error 2 error C1083: Cannot open include file:
'opencv2/core/core.hpp': No such file or
directory c:\users\justin\documents\visual studio
2010\projects\kinectbridgewithopencvbasics-d2d\OpenCVFrameHelper.h 13
Initially I thought these errors were due to forgetting to specify the additional include directories. I added the same property sheet that my other OpenCV projects use to this one, but the errors remained. I tired copying the header files into the project folder: same thing. It seems like the only thing that works is specifying the full absolute file paths in the #include statements. I want to avoid doing this because visual studio wants me to change every #include in every file used in the project, including the openCV header files. I also tried shortening the name of my project folder in case the file path was too long (though I'm pretty sure that's more of an issue for the header file paths), but again no change.
The include directories and #includes that I'm trying to use are the same as in my other projects. I'm using Visual Studio 2010 on Windows 7 x64 based system.
Why would the additional include directory work for other projects, but not this one?
Usually when I see something like this it turns out to be a bad character in one of the prior include paths or other options that's messing everything up after it. I would take a look at your the command line page in the project configuration and see if you can spot anything amiss.

Identifier not found error when compiling a c++ project with qt and opengl

I am trying to compile a C++ program which uses QT and opengl.
When I try to compile it, I am getting this error:
Error 1 error C3861: 'gluErrorString': identifier not found
Looking for this identifier, showed me that it is defined in: line 64 on glu.h file which is part of VS 2012 installation.
Why am I getting this error?
I know that the source code was developed using VS 2010, but I think there should not be any difference, if I use VS 2012.
Should I make any changes to project setup?
First check that you have the line:
#include <glu.h>
somewhere.
Failing that open glu.h and ensure that there are no #defines that are preventing the line being included. You may have to add extra defines to your project.
It can sometime be useful to just run the preprocessor (not sure how to do this in VS) and ensure the symbol is ending up in your cpp file.
After adding the header glu.h also you may get a link error for unresolved symbol gluErrorString. You can solve this by adding the glu32.lib library in the input libraries of the project settings.

Visual Studio 2010, C++, Cannot open include file: 'base.h'

I'm trying to build a project in Visual Studio 2010. But I get the following error:
fatal error C1083: Cannot open include file: 'base.h': No such file or directory
This is a part of the code from (stdafx.h) generating the error:
// from Base project
include "base.h"
include "basic.h"
include "logfile.h"
It seems that the project uses "MFC Microsoft Office Fluent User Interface (the "Fluent UI")".
Do I have to install anything else than Visual Studio for using it?
Something that is missing, that generates the error?
I'm quite new to C++ and Visual Studio.
EDIT:
The problem is that I can't find the files: // from Base project #include "base.h" #include "basic.h" #include "logfile.h" And I don't really know what they are for. I guess some MFC stuff? And they are not anywhere on my disk.
I'm using Windows 7, I don't know on which OS the project is developed on. Can it be that it's developed on WinXP for instance? In that case, do I need to install the SDK for WinXP?
The Fluency UI is part of a MSVC++ feature pack, which you will have to install on top of Visual Studio (you can dowload it following the links in the given page).
In particular the error is due to the fact that the compiler cannot find the file base.h, which could be because it is part of the above mentioned feature pack (and thus it is currently missing) or (if the file does exist on your computer) because your include path (the path the compiler consults for finding included files) is set up incorrectly
Make sure base.h available in the working directory
Right click the base.h (From code editor) and click open document in the context menu (first menu item)
Search that file in your project root folder, then make sure that the path for the file is available in the additional include directory. Project property page --> Select C/C++, first entry on the right side grid.
The problem with this was missing files in the project. Thanks for the help.