4

I installed a new library in vcpkg, i.e, ITK and now I am trying to compile a very first code example available in its guide, I installed it via vcpkg so I skipped the installation part(provided in that guide) and immediately created a new cmake project in visual studio.

+ ItkProjects
    - ItkProjects
        - main.cpp
        - CMakeLists.txt  #1
    - CMakeLists.txt   #2

CMakeLists.txt #2

cmake_minimum_required (VERSION 3.8)

project ("ItkProjects")

# Include sub-projects.
add_subdirectory ("ItkProjects")

CMakeLists.txt #1

cmake_minimum_required (VERSION 3.8)

find_package(ITK CONFIG REQUIRED)

include_directories(${ITK_INCLUDE_DIRS})

add_executable (ItkProjects "main.cpp")

target_link_libraries(ItkProjects ${ITK_LIBRARIES})

main.cpp

#include "itkImage.h"

using namespace std;

int main()
{
    using ImageType = itk::Image<unsigned char, 3>;

    ImageType::Pointer image = ImageType::New();

    return EXIT_SUCCESS;
}

CMake configured and generated with no errors but when compiling I end up with this error:

ninja : error : '/lib/double-conversion.lib', needed by 'ItkProjects/ItkProjects.exe', missing and no known rule to make it

I am sure that this file exist in D:\vcpkg\installed\x64-windows\lib (my installation path) but I am not sure why ninja can't link to it. Please any help..

Mohit
  • 1,225
  • 11
  • 28
  • 2
    Note on the leading `/` in the `/lib/double-conversion.lib`: this means that ninja searches exactly this **absolute** path, without prepending it with anything. Probably, something is wrong with the `vcpkg` package for ITK. – Tsyvarev Jun 25 '19 at 10:32
  • Found an issue in github https://github.com/microsoft/vcpkg/issues/6975 – Mohit Jun 25 '19 at 13:33
  • I am fighting this same error today with ITK + vcpkg + Visual Studio. – drescherjm Oct 23 '19 at 17:04

2 Answers2

3

Have you tried to run cmake with the vcpkg cmake-tool like:

cmake CMakeLists.txt "-DCMAKE_TOOLCHAIN_FILE=D:\src\vcpkg\scripts\buildsystems\vcpkg.cmake"

If I have understood this right this will held to add the correct foldernames. Just found this here: using vcpkg with cmake

KimKulling
  • 2,654
  • 1
  • 15
  • 26
  • I changed it as suggested by vcpkg targets suggested, and it get bit interesting because it is giving many `undefined external symbol` errors when configured with visual studio cmake but it compiles fine when I use the `cmake-gui` for configuring. – Mohit Jun 29 '19 at 13:03
0

Locate the "vcpkg/scripts/buildsystems/vcpkg.cmake" file. Search "VS_GLOBAL_VcpkgEnabled" and change property from false to true.

Oğuzhan Türk
  • 360
  • 2
  • 9
  • 21