Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 运行卡萨布兰卡程序失败';openssl/conf.h';在Mac OS上找不到文件_C++_Macos_Openssl_Casablanca_Cpprest Sdk - Fatal编程技术网

C++ 运行卡萨布兰卡程序失败';openssl/conf.h';在Mac OS上找不到文件

C++ 运行卡萨布兰卡程序失败';openssl/conf.h';在Mac OS上找不到文件,c++,macos,openssl,casablanca,cpprest-sdk,C++,Macos,Openssl,Casablanca,Cpprest Sdk,我正在尝试设置一个Http客户端,并使用所示的示例下载一些数据 当我试着运行程序时,它失败了,说“conf.h”没有找到 $g++ -std=c++11 BingSearch.cpp In file included from BingSearch.cpp:1: In file included from /usr/local/include/cpprest/http_client.h:53: In file included from /usr/local/include/boost/asio

我正在尝试设置一个Http客户端,并使用所示的示例下载一些数据

当我试着运行程序时,它失败了,说“conf.h”没有找到

$g++ -std=c++11 BingSearch.cpp
In file included from BingSearch.cpp:1:
In file included from /usr/local/include/cpprest/http_client.h:53:
In file included from /usr/local/include/boost/asio/ssl.hpp:19:
In file included from /usr/local/include/boost/asio/ssl/context.hpp:27:
In file included from /usr/local/include/boost/asio/ssl/context_base.hpp:19:
/usr/local/include/boost/asio/ssl/detail/openssl_types.hpp:20:10: fatal error: 'openssl/conf.h' file not found
#include <openssl/conf.h>
         ^
1 error generated.
conf.h也位于openssl目录中

openssl $find /usr/local/opt/openssl/ -name "conf.h"
/usr/local/opt/openssl//include/openssl/conf.h

编译下面的文件还需要做些什么吗?这是从我的朋友那里得到的

#包括
#包括
使用命名空间实用程序;//常见的实用程序,如字符串转换
使用命名空间web;//常见的功能,如URI。
使用命名空间web::http;//通用HTTP功能
使用命名空间web::http::client;//HTTP客户端功能
使用命名空间并发::streams;//异步流
int main(int argc,char*argv[])
{
auto fileStream=std::make_shared();
//打开流以输出文件。
pplx::task requestTask=fstream::open_ostream(U(“results.html”))。然后([=](ostream outFile)
{
*fileStream=outFile;
//创建http_客户端以发送请求。
http_客户端(U)http://www.bing.com/"));
//生成请求URI并启动请求。
uri_生成器(U(“/search”);
附加查询(U(“q”)、U(“cpprestsdk github”);
返回client.request(方法::GET,builder.to_string());
})
//处理到达的响应头。
。然后([=](http_响应)
{
printf(“收到的响应状态代码:%u\n”,response.status_code());
//将响应主体写入文件。
返回response.body();
})
//关闭文件流。
。然后([=](大小)
{
返回fileStream->close();
});
//等待所有未完成的I/O完成并处理任何异常
尝试
{
requestTask.wait();
}
捕获(const std::exception&e)
{
printf(“错误异常:%s\n”,例如what());
}
返回0;
}

我尝试了@jww的建议,如下所示

g++ -std=c++11 BingSearch.cpp -lssl -lcrypto -L/usr/local/opt/openssl/lib -I/usr/local/opt/openssl/include
这导致克服了“conf.h”文件未找到错误

但它仍然失败,错误如下

Undefined symbols for architecture x86_64:
  "web::uri_builder::append_query(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)", referenced from:
      web::uri_builder& web::uri_builder::append_query<char [18]>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [18], bool) in BingSearch-582644.o
我的路径变量设置如下

$echo $PATH
/usr/local/opt/openssl/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

“编译此文件还需要执行其他操作吗?”:我们如何知道您何时不向我们显示“此文件”?请发布一个。抱歉,我没有添加代码,因为我添加了一个包含完整代码的链接。请解释下一票的原因。请显示用于编译程序或库的命令行
CPPFLAGS
是C预处理器。您应该将
-I/usr/local/opt/openssl/include
添加到
CFLAGS
(C选项)和
cxflags
(C++选项)。编译器驱动程序的工作是将参数传递给C预处理器;反之亦然。如果它的字面意思是
g++-std=c++11 BingSearch.cpp
,则使用
g++$cxflags-std=c++11 BingSearch.cpp
另请参见、、等。
Undefined symbols for architecture x86_64:
  "web::uri_builder::append_query(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool)", referenced from:
      web::uri_builder& web::uri_builder::append_query<char [18]>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char const (&) [18], bool) in BingSearch-582644.o
g++ -std=c++11 BingSearch.cpp -stdlib=libc++ -lcpprest -lssl -lcrypto -lboost_system -lboost_thread-mt -lboost_chrono-mt -L/usr/local/opt/openssl/lib -I/usr/local/opt/openssl/include
$echo $PATH
/usr/local/opt/openssl/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin