0

I wanted to use dlibc [http://dlib.net/] in Visual studio. I build the dlibc for visual studio according to guide: [https://github.com/davisking/dlib]

C:\libraries\dlib-19.8\build>cmake -G "Visual Studio 14 2015 Win64" -T host=x64 ..
-- Enabling SSE2 instructions
-- Searching for BLAS and LAPACK
-- Searching for BLAS and LAPACK
-- Found Intel MKL BLAS/LAPACK library
-- C++11 activated.
-- Configuring done
-- Generating done
-- Build files have been written to: C:/libraries/dlib-19.8/build

and the project builds successfully and generates following a set of files.

 <DIR>          .
 <DIR>          ..
         24,010 ALL_BUILD.vcxproj
            282 ALL_BUILD.vcxproj.filters
 <DIR>          CMakeFiles
          5,358 cmake_install.cmake
 <DIR>          config
          1,254 config.h
            226 dlib-1.pc
          4,121 dlib.sln
         55,910 dlib.vcxproj
         18,285 dlib.vcxproj.filters
         11,676 INSTALL.vcxproj
            519 INSTALL.vcxproj.filters
 <DIR>          neon_test_build
            129 revision.h

Now I'm wondering how to use it as I could not see any include directories or any dll or lib file. If I add any header files in a C++ console project like

#include <dlib/bayes_utils.h>
#include <dlib/graph_utils.h>

it comes with red wiggles meaning file not found.

I'm very new to visual studio IDE.

Update 1: Still Fails

I opened the dlib.sln file with VS and build the install configuration. It got success with message like this:

  -- Install configuration: "Debug"
  -- Installing: C:/Program Files/Project/lib/dlib.lib

then I added C:/Program Files/Project/include/dlib/; in Additional include directories of project settings and tried to run a sample code http://dlib.net/bayes_net_ex.cpp.html but still the red wiggles are there.

Kumar Roshan Mehta
  • 3,078
  • 2
  • 27
  • 50
  • 1
    Don't post screenshots of the console window. Post its content. It would also be nice to post the output of an appropriate `dir` command instead of posting an Explorer screenshot. This isn't Facebook, after all. – Christian Hackl Dec 23 '17 at 11:18
  • Done, I will take care of it from now on. – Kumar Roshan Mehta Dec 23 '17 at 11:27
  • Thanks! The goal is to enhance findability with search engines like Google for people who will have the same problem in the future. – Christian Hackl Dec 23 '17 at 11:30
  • What happens when you open the *.sln file with Visual Studio? Doesn't it then offer you to build the library? – Christian Hackl Dec 23 '17 at 11:34
  • Updated the answer with the latest attempt. – Kumar Roshan Mehta Dec 23 '17 at 11:57
  • Does `C:/Program Files/Project/include/dlib/` exist on your computer? – Christian Hackl Dec 23 '17 at 12:12
  • Obviously yes. I got it after building dlib.sln file – Kumar Roshan Mehta Dec 23 '17 at 12:16
  • You should really use cmake to generate your project, rather than installing dlib. There is a tutorial here: http://dlib.net/examples/CMakeLists.txt.html – Davis King Dec 23 '17 at 12:44
  • Part of the reason you should use CMake rather than installing and setting up visual studio yourself is because visual studio has a lot of different and incompatible runtimes. So this means that, for instance, if you compile and install a library in debug mode you can only use that library in debug mode visual studio projects. To use release mode you will need to compile and install a separate copy in release mode. This is very inconvenient. But if you use cmake to setup your project it will do it all correctly and you won't be bothered by these kinds of visual studio details. – Davis King Dec 23 '17 at 12:47
  • Possible duplicate of [How to add additional libraries to Visual Studio project?](https://stackoverflow.com/q/4445418/608639), [Compiling and linking third party libraries in VS 2015](https://stackoverflow.com/q/31030556/608639), etc. – jww Mar 02 '19 at 06:48

2 Answers2

0
#include <dlib/bayes_utils.h>
#include <dlib/graph_utils.h>

[...]

then I added C:/Program Files/Project/include/dlib/; in Additional include directories

A line like #include <dlib/...> means that the compiler searches all include directories for a subdirectory named dlib. Unless there is a directory C:/Program Files/Project/include/dlib/dlib on your machine, which I doubt, then this will fail.

You should instead add C:\Program Files\Project\include. Also consider adding include directories and library directories through "Property Manager / Release | Win32 / Microsoft.Cpp.Win32.user".


As an aside, that's a very unusual destination path chosen by CMake. Chances are that this has something to do with a new CMake version, or you did something else with the generated files you haven't told us about.

Christian Hackl
  • 27,051
  • 3
  • 32
  • 62
  • It's tested plenty with that version of visual studio and there is nothing in dlib's cmake files that set the target install folder. It's either a new default in the new cmake or the OP has set something he hasn't told us about. – Davis King Dec 23 '17 at 12:45
  • @DavisKing: Good to know. I'll adapt that paragraph! – Christian Hackl Dec 23 '17 at 12:47
0

You can configure the compiler file path location for the include files in visual studio. In the properties of the project, select C/C++ General menu and add the folder location to: Additional Include Directories.

Alain
  • 109
  • 2