-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cannot compile sample on OSX #458
Comments
I met the same problem. What I did is to explicitly link to the openssl libs to solve this. Actually, in order to make the sample code work, I have to link to a bunch of libs from boost as well. I deem this is problem of cpprest. For sure, itself has dependencies on openssl and boost, but the sample code clearly does not rely on them directly. Why including a head file of cpprest would require me to link to openssl and boost explicitly? |
I you use VisualStudio Code for macOS this configuration worked for me:
to run the HTTP_Client example |
My apology to reactivate this rather old issue, the build is failing again with the macOS Catalina (Version 10.15). @BillyONeal Here is what I did:
Here is my CMakeLists.txt
It appears that and here is my main.cpp #include <cpprest/http_client.h>
#include <cpprest/filestream.h>
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
int main(int argc, char* argv[])
{
auto fileStream = std::make_shared<ostream>();
// Open stream to output file.
pplx::task<void> requestTask = fstream::open_ostream(U("results.html")).then([=](ostream outFile)
{
*fileStream = outFile;
// Create http_client to send the request.
http_client client(U("http://www.bing.com/"));
// Build request URI and start the request.
uri_builder builder(U("/search"));
builder.append_query(U("q"), U("cpprestsdk github"));
return client.request(methods::GET, builder.to_string());
})
// Handle response headers arriving.
.then([=](http_response response)
{
printf("Received response status code:%u\n", response.status_code());
// Write response body into the file.
return response.body().read_to_end(fileStream->streambuf());
})
// Close the file stream.
.then([=](size_t)
{
return fileStream->close();
});
// Wait for all the outstanding I/O to complete and handle any exceptions
try
{
requestTask.wait();
}
catch (const std::exception &e)
{
printf("Error exception:%s\n", e.what());
}
return 0;
} And I have got this weirdo errors:
|
I just received this today after a MacOS update to Catalina. |
This is probably the problem: |
Has this been fixed ? |
Not as far as I know. |
I moved on, so I can't answer. |
I did this and that worked
taken from https://www.anintegratedworld.com/mac-osx-fatal-error-opensslsha-h-file-not-found/ |
I'm on OSX El Capitan, I did an install using the instructions located here.
$ brew install cpprestsdk
I copied the sample code from here and tried to compile it, but get this error:
I tried adding -I and -L flags to the g++ arguments like this:
g++ -std=c++11 test.cpp -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
But then I get a bunch more errors: (the first few are shown below)
I'm not sure how to proceed from here. Thanks for any help.
The text was updated successfully, but these errors were encountered: