我今天安装了 vcpkg,启用了与 Visual Studio 的集成,即 .\vcpkg 集成安装,并开始安装库。
我基本上安装了 cpprestsdk 并触发了 boost 库的安装。然后我在 Visual Studio (CMake) 中打开了该项目。
当我安装 cpprestsdk 时,我收到了这条消息:
The package cpprestsdk:x86-windows provides CMake targets:
find_package(cpprestsdk REQUIRED)
# Note: 1 targets were omitted
target_link_libraries(main PRIVATE cpprestsdk::cpprest cpprestsdk::cpprestsdk_boost_internal cpprestsdk::cpprestsdk_zlib_internal cpprestsdk::cp
prestsdk_openssl_internal)
The package cpprestsdk:x64-windows provides CMake targets:
find_package(cpprestsdk REQUIRED)
# Note: 1 targets were omitted
target_link_libraries(main PRIVATE cpprestsdk::cpprest cpprestsdk::cpprestsdk_boost_internal cpprestsdk::cpprestsdk_zlib_internal cpprestsdk::cp
prestsdk_openssl_internal)
所以我的 CMakeLists.txt
cmake_minimum_required (VERSION 2.8)
project(CppRestSwaggerClient)
#find_package(Boost REQUIRED)
# THE LOCATION OF OUTPUT BINARIES
set(CMAKE_LIBRARY_DIR ${PROJECT_SOURCE_DIR}/lib)
set(LIBRARY_OUTPUT_PATH ${CMAKE_LIBRARY_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Update require components as necessary
#find_package(Boost 1.45.0 REQUIRED COMPONENTS ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_FILESYSTEM_LIBRARY})
find_package(cpprestsdk REQUIRED)
message("this is ${Boost_INCLUDE_DIRS}")
# build and set path to cpp rest sdk
set(CPPREST_ROOT ${PROJECT_SOURCE_DIR}/../../../vcpkg/packages/cpprestsdk_x86-windows)
set(CPPREST_INCLUDE_DIR ${CPPREST_ROOT}/include)
#set(CPPREST_LIBRARY_DIR ${CPPREST_ROOT}/lib)
include_directories(${PROJECT_SOURCE_DIR} api model ${CPPREST_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})
#include_directories(${PROJECT_SOURCE_DIR} api model ${CPPREST_INCLUDE_DIR})
#SUPPORTING FILES
set(SUPPORTING_FILES "ApiClient" "ApiConfiguration" "ApiException" "HttpContent" "IHttpBody" "JsonBody" "ModelBase" "MultipartFormData" "Object")
#SOURCE FILES
file(GLOB SOURCE_FILES "api/*" "model/*")
add_library(${PROJECT_NAME} ${SUPPORTING_FILES} ${SOURCE_FILES} )
但是,当我构建项目时,我遇到了一些关于提升的错误
c:\code\cpprest-client\multipartformdata.cpp(16):致命错误 C1083:无法打开包含文件:'boost/uuid/random_generator.hpp':没有这样的文件或目录
和
c:\code\cpprest-client\api\userapi.h(36):致命错误 C1083:无法打开包含文件:'boost/optional.hpp':没有这样的文件或目录
在我的 powershell 中,我看到安装了这些库
PS C:\vcpkg\packages> ls .\boost-uuid_x86-windows
Directory: C:\vcpkg\packages\boost-uuid_x86-windows
任何想法,发生了什么。我已经为此浪费了几个小时。
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 5/11/2018 11:47 AM include
d----- 5/11/2018 11:47 AM share
-a---- 5/11/2018 11:47 AM 46 BUILD_INFO
-a---- 5/11/2018 11:47 AM 405 CONTROL
PS C:\vcpkg\packages> ls .\boost-optional_x64-windows
Directory: C:\vcpkg\packages\boost-optional_x64-windows
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 5/11/2018 1:25 PM include
d----- 5/11/2018 1:25 PM share
-a---- 5/11/2018 1:25 PM 46 BUILD_INFO
-a---- 5/11/2018 1:25 PM 302 CONTROL