Can you debug this?

closed account (zqMDizwU)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
//  curl_util.cpp
//  quote

#include "curl_util.h"
#include <memory>
#include <stdexcept>
#include <string>
#include <utility>
#include <curl.h>

namespace quote {
	namespace detail {
		namespace curl_util {
			std::shared_ptr<CURL> createCurlHandle() {
				std::shared_ptr<CURL> curlHandle(curl_easy_init(), curl_easy_cleanup);
				if (curlHandle.get() == nullptr) {
					throw std::runtime_error("curl_easy_init() failure");
				}
				return curlHandle;
			};

			void perform(CURL *handle) {
				CURLcode code = curl_easy_perform(handle);
				if (code != CURLE_OK) {
					throw std::runtime_error(std::string("curl_easy_perform error: ") + curl_easy_strerror(code));
				}
			}

			size_t writeToStringCallBack(void *buffer, size_t size, size_t nmemb, void *string) {
				const size_t sizeInBytes = size*nmemb;
				static_cast<std::string *>(string)->append(static_cast<const char * >(buffer), sizeInBytes);
				return sizeInBytes;
			}

			std::string getUrlData(const std::string url) {
				std::shared_ptr<CURL> curlHandle = detail::curl_util::createCurlHandle();
				detail::curl_util::setOpt(curlHandle.get(), CURLOPT_URL, url.c_str());
				detail::curl_util::setOpt(curlHandle.get(), CURLOPT_FOLLOWLOCATION, 1L);
				std::string data;
				detail::curl_util::setOpt(curlHandle.get(), CURLOPT_NOBODY, 0L);
				detail::curl_util::setOpt(curlHandle.get(), CURLOPT_WRITEDATA, &data);
				detail::curl_util::setOpt(curlHandle.get(), CURLOPT_WRITEFUNCTION, detail::curl_util::writeToStringCallBack);
				detail::curl_util::perform(curlHandle.get());
				return std::move(data);
			}
		}
	}
}


Error 1 error LNK2019: unresolved external symbol __imp__curl_easy_strerror referenced in function "void __cdecl quote::detail::curl_util::setOpt<long>(void *,enum CURLoption,long)" (??$setOpt@J@curl_util@detail@quote@@YAXPAXW4CURLoption@@J@Z) C:\Users\MathewFok\documents\visual studio 2013\Projects\C++\C++\curl_util.obj C++
Error 3 error LNK2019: unresolved external symbol __imp__curl_easy_setopt referenced in function "void __cdecl quote::detail::curl_util::setOpt<long>(void *,enum CURLoption,long)" (??$setOpt@J@curl_util@detail@quote@@YAXPAXW4CURLoption@@J@Z) C:\Users\MathewFok\documents\visual studio 2013\Projects\C++\C++\curl_util.obj C++
Error 4 error LNK2019: unresolved external symbol __imp__curl_easy_perform referenced in function "void __cdecl quote::detail::curl_util::perform(void *)" (?perform@curl_util@detail@quote@@YAXPAX@Z) C:\Users\MathewFok\documents\visual studio 2013\Projects\C++\C++\curl_util.obj C++
Error 2 error LNK2019: unresolved external symbol __imp__curl_easy_init referenced in function "class std::shared_ptr<void> __cdecl quote::detail::curl_util::createCurlHandle(void)" (?createCurlHandle@curl_util@detail@quote@@YA?AV?$shared_ptr@X@std@@XZ) C:\Users\MathewFok\documents\visual studio 2013\Projects\C++\C++\curl_util.obj C++
Error 5 error LNK2019: unresolved external symbol __imp__curl_easy_cleanup referenced in function "class std::shared_ptr<void> __cdecl quote::detail::curl_util::createCurlHandle(void)" (?createCurlHandle@curl_util@detail@quote@@YA?AV?$shared_ptr@X@std@@XZ) C:\Users\MathewFok\documents\visual studio 2013\Projects\C++\C++\curl_util.obj C++
Error 6 error LNK1120: 5 unresolved externals C:\Users\MathewFok\documents\visual studio 2013\Projects\C++\Debug\C++.exe C++
Looks like you did not link CURL library.
closed account (zqMDizwU)
I did. I went to my project's properties and then linked the include file under c++ general properties. It was giving me errors with the #include <curl/curl.h> files so I just pulled in curl.h into my project's header files.

Am I not connecting the libcurl library correctly?
linked the include file
include file? Shouldn't it be .a files?
Also you should compile with -DCURL_STATICLIB option.
I went to my project's properties and then linked the include file under c++ general properties.
MiniPaa is referring to the CURL object library, not the header file.
The linker errors are all saying that various CURL routines were not found.
closed account (zqMDizwU)
Ok I will look to see how to find the objects "included"
Topic archived. No new replies allowed.