title: c++ cmake linking libconfig++
body: <p>I did install package libconfig with Microsoft/vcpkg manager on Windows. And in Visual Studio trying to link libconfig++ to my project but it can't be linked.</p>
  
  <p><strong>CMakeLists.txt</strong></p>
  
  <pre><code>cmake_minimum_required(VERSION 3.10)
  set(CMAKE_CXX_STANDARD 17)
  
  ############ Project name and version
  set (TEST_MAJOR_VERSION 1)
  set (TEST_MINOR_VERSION 0)
  set (TEST_PATCH_VERSION 0)
  set (TEST_VERSION ${TEST_MAJOR_VERSION}.${TEST_MINOR_VERSION}.${TEST_PATCH_VERSION})
  
  # Include our cmake macros
  set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
  include (CMakeHelpers)
  
  ############ Add projects
  
  # Add main library
  add_subdirectory (src)
  
  init_target (test)
  
  if(_version_allowed STREQUAL NEW)
      message (STATUS "==== set project " ${TARGET_NAME})
      project (${TARGET_NAME} VERSION ${TEST_VERSION})
  else()
      project (${TARGET_NAME})
  endif()
  
  
  file (GLOB SOURCE_FILES 
      *.cpp)
  file (GLOB HEADER_FILES 
      *.h)
  
  find_package(libconfig)
  
  if(WIN32)
      link_directories(G:/_Development/Projects/cpprestsdk/vcpkg/installed/x64-windows/lib)
      include_directories(G:/_Development/Projects/cpprestsdk/vcpkg/installed/x64-windows/include)
  endif()
  
  add_executable(${TARGET_NAME} ${SOURCE_FILES} ${HEADER_FILES})
  target_link_libraries(test PRIVATE libconfig)
  </code></pre>
  
  <p><strong>test.cpp</strong></p>
  
  <pre><code>#include &lt;libconfig.h++&gt;
  
  using namespace libconfig;
  
  int main(int argc, char* argv[])
  {
      // libconfig
      Config cfg;
  
      return 0;
  }
  </code></pre>
  
  <p>Errors:</p>
  
  <blockquote>
    <blockquote>
      <p>------ Rebuild started: Project: CMakeLists, Configuration: RelWithDebInfo ------   Cleaning... 0 files.   [1/2]
      C:\PROGRA~2\MIB055~1\2017\PROFES~1\VC\Tools\MSVC\1416~1.270\bin\HostX64\x64\cl.exe
      /nologo /TP  -IG:_Development\Projects\cppTest\src
      -IG:_Development\Projects\cpprestsdk\vcpkg\installed\x64-windows\include
      /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MD /Zi /O2 /Ob1 /DNDEBUG<br>
      -std:c++17 /showIncludes /Fosrc\CMakeFiles\test.dir\test.cpp.obj /Fdsrc\CMakeFiles\test.dir\ /FS -c
      G:_Development\Projects\cppTest\src\test.cpp
      G:_Development\Projects\cpprestsdk\vcpkg\installed\x64-windows\include\libconfig.h++(51):
      warning C4275: non dll-interface class 'std::exception' used as base
      for dll-interface class 'libconfig::ConfigException'   C:\Program
      Files (x86)\Microsoft Visual
      Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vcruntime_exception.h(44):
      note: see declaration of 'std::exception'<br>
      G:_Development\Projects\cpprestsdk\vcpkg\installed\x64-windows\include\libconfig.h++(51):
      note: see declaration of 'libconfig::ConfigException'   [2/2] cmd.exe
      /C "cd . &amp;&amp; "C:\Program Files (x86)\Microsoft Visual
      Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
      -E vs_link_exe --intdir=src\CMakeFiles\test.dir --manifests  -- C:\PROGRA~2\MIB055~1\2017\PROFES~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\link.exe
      /nologo src\CMakeFiles\test.dir\test.cpp.obj  /out:src\test.exe
      /implib:src\test.lib /pdb:src\test.pdb /version:0.0  /machine:x64
      /debug /INCREMENTAL /subsystem:console
      -LIBPATH:G:_Development\Projects\cpprestsdk\vcpkg\installed\x64-windows\lib
      libconfig.lib kernel32.lib user32.lib gdi32.lib winspool.lib
      shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
      &amp;&amp; cd ."   FAILED: src/test.exe    cmd.exe /C "cd . &amp;&amp; "C:\Program
      Files (x86)\Microsoft Visual
      Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
      -E vs_link_exe --intdir=src\CMakeFiles\test.dir --manifests  -- C:\PROGRA~2\MIB055~1\2017\PROFES~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\link.exe
      /nologo src\CMakeFiles\test.dir\test.cpp.obj  /out:src\test.exe
      /implib:src\test.lib /pdb:src\test.pdb /version:0.0  /machine:x64
      /debug /INCREMENTAL /subsystem:console
      -LIBPATH:G:_Development\Projects\cpprestsdk\vcpkg\installed\x64-windows\lib
      libconfig.lib kernel32.lib user32.lib gdi32.lib winspool.lib
      shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
      &amp;&amp; cd ."   LINK Pass 1: command
      "C:\PROGRA~2\MIB055~1\2017\PROFES~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\link.exe
      /nologo src\CMakeFiles\test.dir\test.cpp.obj /out:src\test.exe
      /implib:src\test.lib /pdb:src\test.pdb /version:0.0 /machine:x64
      /debug /INCREMENTAL /subsystem:console
      -LIBPATH:G:_Development\Projects\cpprestsdk\vcpkg\installed\x64-windows\lib
      libconfig.lib kernel32.lib user32.lib gdi32.lib winspool.lib
      shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
      /MANIFEST /MANIFESTFILE:src\CMakeFiles\test.dir/intermediate.manifest
      src\CMakeFiles\test.dir/manifest.res" failed (exit code 1120) with the
      following output: C:\Program Files (x86)\Microsoft Visual
      Studio\2017\Professional\Common7\IDE\test.cpp.obj : error LNK2019:
      unresolved external symbol "__declspec(dllimport) public: __cdecl
      libconfig::Config::Config(void)" (__imp_??0Config@libconfig@@QEAA@XZ)
      referenced in function main C:\Program Files (x86)\Microsoft Visual
      Studio\2017\Professional\Common7\IDE\test.cpp.obj : error LNK2019:
      unresolved external symbol "__declspec(dllimport) public: virtual
      __cdecl libconfig::Config::~Config(void)" (__imp_??1Config@libconfig@@UEAA@XZ) referenced in function main
      C:\Program Files (x86)\Microsoft Visual
      Studio\2017\Professional\Common7\IDE\src\test.exe : fatal error
      LNK1120: 2 unresolved externals   ninja: build stopped: subcommand
      failed.</p>
    </blockquote>
    
    <p>Build failed.</p>
  </blockquote>
  
  <p>What is wrong? </p>