2017-10-13 270 views
2

我正在使用C++ RESTAPI的项目。进入Casablanca教程。根据该教程,我使用NuGet包管理器将Casablanca添加到我的C++项目中。我使用Visual Studio 2015企业版。但是当包含以下文件时,它会在#include <cpprest/ws_client>上显示错误。我已经按照如下方式设置了“附加包含”目录和“附加库目录”形式的项目属性。无法打开包含文件:'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也不过结果是一样的。)

回答

1

你不包括头文件的权利,因此,参考不能得到解决:使用#include <cpprest/ws_client.h>代替#include <cpprest/ws_client>将为你工作。

+0

是的。官方网页教程出错了。我认为这是一个错误。谢谢我修复它。 – Nwn

相关问题