1

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.

Vuwox
  • 2,331
  • 18
  • 33

1 Answers1

1

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

Evgeniy
  • 2,481
  • 14
  • 24
  • There is no custom "windows.h" in my project. And I don't get what you means by : "You can try using this function separate from dlib and ..." ? – Vuwox Apr 25 '17 at 15:07
  • you can try calling WaitForSingleObject function from your concole application. will it produce errors? if yes - something with include paths and files, if no - something in dlib files including order or may be dlib is corrupted – Evgeniy Apr 25 '17 at 15:13
  • I'm currently testing that. So I didn't include any thing that related do dlib. Can compile. Next, I add a `GetCurrentThreadId()` in my cpp (easier to call compare to `WaitForSingleObject­`). As you said, I still have the undefined on `GetCurrentThreadId`. Then, I add the `Windows.h` into that cpp and the error gone, can compile. But when I re-add the header to the dlib call. Still have undefined on `GetCurrentThreadId`. But I noticed that without `Windows.h` I have 50 errors and with only 25 errors. There might be a `Windows.h` issue somewhere else right ? – Vuwox Apr 25 '17 at 15:40
  • Found out. There was another .cpp where `windows.h` was needed. Thanks – Vuwox Apr 25 '17 at 16:01