c++ - 无法打开包含文件 : 'cpprest/ws_client' : No such file or directory

标签 c++ rest visual-studio-2015 sdk casablanca

我正在开发一个使用 C++ RESTAPI 的项目。我正在关注 Casablanca教程。根据该教程,我使用 NuGet 包管理器将 Casablanca 添加到我的 C++ 项目中。我使用的是 Visual Studio 2015 企业版。但是当包含以下文件时,它会在 #include <cpprest/ws_client> 上显示错误.我已经设置了附加包含目录,附加库目录形成项目属性,如下所示。

附加包含目录 <project_dir>\packages\cpprestsdk.v140.windesktop.msvcstl.dyn.rt-dyn.2.9.1\build\native\include

其他图书馆目录 <project_dir>\packages\cpprestsdk.v140.windesktop.msvcstl.dyn.rt-dyn.2.9.1\lib

我在这里添加了实际的屏幕截图。如何解决这个问题? enter image description here

#include <iostream>
#include <cpprest/http_client.h>
#include <cpprest/filestream.h>
#include <cpprest/http_listener.h>              // HTTP server
#include <cpprest/json.h>                       // JSON library
#include <cpprest/uri.h>                        // URI library
#include <cpprest/ws_client>                    // WebSocket client
#include <cpprest/containerstream.h>            // Async streams backed by STL containers
#include <cpprest/interopstream.h>              // Bridges for integrating Async streams with STL and WinRT streams
#include <cpprest/rawptrstream.h>               // Async streams backed by raw pointer to memory
#include <cpprest/producerconsumerstream.h>     // Async streams for producer consumer scenarios

using namespace utility;                    // Common utilities like string conversions
using namespace web;                        // Common features like URIs.
using namespace web::http;                  // Common HTTP functionality
using namespace web::http::client;          // HTTP client features
using namespace concurrency::streams;       // Asynchronous streams
using namespace web::http::experimental::listener;          // HTTP server
using namespace web::experimental::web_sockets::client;     // WebSockets client
using namespace web::json;                                  // JSON library 

(我也尝试过 visual Studio 2017,2013。但结果是一样的。)

最佳答案

您没有正确包含头文件,因此无法解析引用:使用 #include <cpprest/ws_client.h>而不是 #include <cpprest/ws_client>会为你工作。

关于c++ - 无法打开包含文件 : 'cpprest/ws_client' : No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46722326/

相关文章:

c# - 在 CommandBar 的 SecondaryCommand 上设置图标

visual-studio - 如何在 Visual Studio 上以管理员身份运行最近的项目或解决方案

c++ - 输出是打印出您输入的矩阵的矩阵转置,但我的代码只是打印出您输入的第一个矩阵

c++ - 缓存对象应该直接从文件系统读取吗?

java - 无法使用 DOM 从 XML 结果中解析元素

jQuery 的 ajaxSetup - 我想仅为 GET 请求添加默认数据

c++ - 由元素和其他集合组成的集合,用于在 C++ 中构造集合

c++ - 为什么我们不能在 C++ 中进行三向比较?

java - 改造:500 内部服务器错误

c++ - 从 win32 python 扩展构建编译 PythonService.cpp