Compiling Error: LNK 2019

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
/
//  curl_util.h
//  quote

#ifndef curl_util_h
#define curl_util_h

#include <memory>
#include <stdexcept>
#include <string>
#include <curl.h>

namespace quote {
	namespace detail {
		namespace curl_util {
			std::shared_ptr<CURL> createCurlHandle();

			template<typename T>
			void setOpt(CURL *handle, CURLoption option, T parameter);

			void perform(CURL *handle);

			size_t writeToStringCallBack(void *buffer, size_t size, size_t nmemb, void *string);

			std::string getUrlData(const std::string url);

			//--

			template<typename T>
			void setOpt(CURL *handle, CURLoption option, T parameter) {
				CURLcode code = curl_easy_setopt(handle, option, parameter);
				if (code != CURLE_OK) {
					throw std::runtime_error(std::string("curl_easy_setopt error: ") + curl_easy_strerror(code));
				}
			}
		}
	}
}


#endif 


error 2 out of 7 shown:

Error 2 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 4 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++







1>------ Build started: Project: C++, Configuration: Debug Win32 ------
1> 123.cpp
1> Generating Code...
1> Compiling...
1> core.cpp
1> Generating Code...
1> Compiling...
1> curl_util.cpp
1> Generating Code...
1> Skipping... (no relevant changes detected)
1> conversion.cpp
1>123.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl quote::getLatestQuotesCsv(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::initializer_list<enum quote::QuoteType>)" (?getLatestQuotesCsv@quote@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV23@V?$initializer_list@W4QuoteType@quote@@@3@@Z) referenced in function _main
1>curl_util.obj : 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)
1>curl_util.obj : 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)
1>curl_util.obj : 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)
1>curl_util.obj : 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)
1>curl_util.obj : 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)
1>C:\Users\MathewFok\Documents\Visual Studio 2013\Projects\C++\Debug\C++.exe : fatal error LNK1120: 6 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
setOpt() is a template function, so it has to be declared and defined in the same file.

By the way, CURL is the libcurl instance, right? boost::shared_ptr can only be used with objects that were allocated by new. libcurl is a C library, so it doesn't use new.
Topic archived. No new replies allowed.