c++ - 如何使用 Xcode 8.2.1 在我的项目中添加 cpprestsdk 库

标签 c++ xcode

我使用 Mac,是 Xcode 和 C++ 的初学者。我使用 brew install cpprestsdk 安装了一个库。然后我将 Xcode 中的 header 搜索路径设置为 /usr/local/Cellar/cpprestsdk/2.9.1/include/cpprest 用于 Debug 和 Release 以便自动完成工作。

我正在努力学习本教程 https://github.com/Microsoft/cpprestsdk/wiki/Getting-Started-Tutorial所以我写了一个小程序:

#include <iostream>
#include <http_client.h>
#include <filestream.h>

int main(int argc, const char * argv[]) {
    return 0;
}

但当我尝试运行该程序时,出现“词法或预处理器问题”,指出 pplx/pplxtasks.h 文件未在 http_client 中找到。有没有我遗漏的步骤?

最佳答案

我使用 brew install cpprestsdk 安装

您需要将额外的 header 搜索路径设置为 /usr/local/include .将同时找到 cpprestsdkpplx作为彼此的同龄人。然后使用这个:

#include <cpprest/http_client.h>

然后您将遇到 fatal error :找不到“openssl/conf.h”文件,请参见https://github.com/Microsoft/cpprestsdk/issues/458

...导致需要像这样的标题搜索路径: /usr/local/include; /usr/local/opt/openssl/include

和库搜索路径如下: /usr/local/opt/cpprestsdk/lib; /usr/local/opt/openssl/lib; /usr/local/opt/boost/lib

和额外的链接器标志,如下所示: -lcpprest -lssl -lcrypto -lboost_system -lboost_thread-mt -lboost_chrono-mt

关于c++ - 如何使用 Xcode 8.2.1 在我的项目中添加 cpprestsdk 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45437584/

相关文章:

c++ - 如何添加空格字符以触发var args c++ execlp()

c++ - 我如何在 Boost Spirit 中实现 const?

c++ - 是否可以仅在 if 语句的范围内定义变量,类似于 for 循环的常见做法?

c++ - 编译c/cpp文件时scons "Depends"什么时候有用?

c++ - 如何在 struct 数据结构中使用 map STL 并初始化 map 然后引用它?

iphone - Obj-C @synthesize

ios - 不支持推送导航 Controller - 自 Xcode 6.2 更新以来

xcode - 如何将 UI 元素连接到 IBOutlets 和 IBActions?

ios - 在非测试目标中使用 XCTest

xcode - 在哪里可以下载旧版本的 Xcode?