Closed divonelnc closed 1 year ago
How are you integrating liboai
? As a compiled library and linking to it, or using liboai
's source code in your project?
I downloaded the source code, then added the include folder to the Additional include directories in Visual studio.
I downloaded the source code, then added the include folder to the Additional include directories in Visual studio.
This is fine, but when using the source code, it is important to include the implementation files so the compiler can find them alongside the header files. Your errors describe that your compiler is unable to find the implementation code for the methods:
virtual __cdecl liboai::netimpl::Session::~Session
liboai::Response __cdecl liboai::netimpl::Session::Get
liboai::Response __cdecl liboai::netimpl::Session::Post
liboai::Response __cdecl liboai::netimpl::Session::Delete
void __cdecl liboai::netimpl::Session::SetOption(class liboai::netimpl::components::Url const &)
void __cdecl liboai::netimpl::Session::SetOption(class std::map<...>)
All of these functions' implementations reside in netimpl.cpp
. Ensure your compiler can find all implementation files and their associated header files.
I have added the core (where netimpl.cpp
is located) and even the component folders to the project's dependencies, but I am still getting the same errors :(
I have added the core (where
netimpl.cpp
is located) and even the component folders to the project's dependencies, but I am still getting the same errors :(
The implementation files need to be within VS themselves as well like shown below.
Simply telling VS that the files exist isn't the same as actually placing them into VS so that the compiler can make use of them.
I now have the same solution tree as on your picture, but if anything it added more unresolved errors:
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_mime_init referenced in function "private: void __cdecl liboai::netimpl::Session::SetMultipart(class liboai::netimpl::components::Multipart &&)" (?SetMultipart@Session@netimpl@liboai@@AEAAX$$QEAVMultipart@components@23@@Z)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_mime_free referenced in function "public: virtual __cdecl liboai::netimpl::Session::~Session(void)" (??1Session@netimpl@liboai@@UEAA@XZ)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_mime_addpart referenced in function "private: void __cdecl liboai::netimpl::Session::SetMultipart(class liboai::netimpl::components::Multipart &&)" (?SetMultipart@Session@netimpl@liboai@@AEAAX$$QEAVMultipart@components@23@@Z)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_mime_name referenced in function "private: void __cdecl liboai::netimpl::Session::SetMultipart(class liboai::netimpl::components::Multipart &&)" (?SetMultipart@Session@netimpl@liboai@@AEAAX$$QEAVMultipart@components@23@@Z)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_mime_filename referenced in function "private: void __cdecl liboai::netimpl::Session::SetMultipart(class liboai::netimpl::components::Multipart &&)" (?SetMultipart@Session@netimpl@liboai@@AEAAX$$QEAVMultipart@components@23@@Z)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_mime_type referenced in function "private: void __cdecl liboai::netimpl::Session::SetMultipart(class liboai::netimpl::components::Multipart &&)" (?SetMultipart@Session@netimpl@liboai@@AEAAX$$QEAVMultipart@components@23@@Z)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_mime_data referenced in function "private: void __cdecl liboai::netimpl::Session::SetMultipart(class liboai::netimpl::components::Multipart &&)" (?SetMultipart@Session@netimpl@liboai@@AEAAX$$QEAVMultipart@components@23@@Z)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_mime_filedata referenced in function "private: void __cdecl liboai::netimpl::Session::SetMultipart(class liboai::netimpl::components::Multipart &&)" (?SetMultipart@Session@netimpl@liboai@@AEAAX$$QEAVMultipart@components@23@@Z)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_easy_escape referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl liboai::netimpl::CurlHolder::urlEncode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?urlEncode@CurlHolder@netimpl@liboai@@QEAA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV45@@Z)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_easy_unescape referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl liboai::netimpl::CurlHolder::urlDecode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?urlDecode@CurlHolder@netimpl@liboai@@QEAA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV45@@Z)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_free referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl liboai::netimpl::CurlHolder::urlDecode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?urlDecode@CurlHolder@netimpl@liboai@@QEAA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV45@@Z)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_slist_append referenced in function "private: void __cdecl liboai::netimpl::Session::SetHeader(class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct liboai::netimpl::components::CaseInsensitiveCompare,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > const &)" (?SetHeader@Session@netimpl@liboai@@AEAAXAEBV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@UCaseInsensitiveCompare@components@netimpl@liboai@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@Z)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_slist_free_all referenced in function "public: virtual __cdecl liboai::netimpl::Session::~Session(void)" (??1Session@netimpl@liboai@@UEAA@XZ)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_version_info referenced in function "public: __cdecl liboai::netimpl::CurlHolder::CurlHolder(void)" (??0CurlHolder@netimpl@liboai@@QEAA@XZ)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_easy_strerror referenced in function "public: __cdecl liboai::netimpl::CurlHolder::CurlHolder(void)" (??0CurlHolder@netimpl@liboai@@QEAA@XZ)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_easy_init referenced in function "public: __cdecl liboai::netimpl::CurlHolder::CurlHolder(void)" (??0CurlHolder@netimpl@liboai@@QEAA@XZ)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_easy_setopt referenced in function "private: class liboai::Response __cdecl liboai::netimpl::Session::CompleteDownload(void)" (?CompleteDownload@Session@netimpl@liboai@@AEAA?AVResponse@3@XZ)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_easy_perform referenced in function "private: enum CURLcode __cdecl liboai::netimpl::Session::Perform(void)" (?Perform@Session@netimpl@liboai@@AEAA?AW4CURLcode@@XZ)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_easy_cleanup referenced in function "public: virtual __cdecl liboai::netimpl::CurlHolder::~CurlHolder(void)" (??1CurlHolder@netimpl@liboai@@UEAA@XZ)
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_easy_getinfo referenced in function "private: class liboai::Response __cdecl liboai::netimpl::Session::BuildResponseObject(void)" (?BuildResponseObject@Session@netimpl@liboai@@AEAA?AVResponse@3@XZ)
I now have the same solution tree as on your picture, but if anything it added more unresolved errors:
1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_mime_init referenced in function "private: void __cdecl liboai::netimpl::Session::SetMultipart(class liboai::netimpl::components::Multipart &&)" (?SetMultipart@Session@netimpl@liboai@@AEAAX$$QEAVMultipart@components@23@@Z) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_mime_free referenced in function "public: virtual __cdecl liboai::netimpl::Session::~Session(void)" (??1Session@netimpl@liboai@@UEAA@XZ) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_mime_addpart referenced in function "private: void __cdecl liboai::netimpl::Session::SetMultipart(class liboai::netimpl::components::Multipart &&)" (?SetMultipart@Session@netimpl@liboai@@AEAAX$$QEAVMultipart@components@23@@Z) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_mime_name referenced in function "private: void __cdecl liboai::netimpl::Session::SetMultipart(class liboai::netimpl::components::Multipart &&)" (?SetMultipart@Session@netimpl@liboai@@AEAAX$$QEAVMultipart@components@23@@Z) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_mime_filename referenced in function "private: void __cdecl liboai::netimpl::Session::SetMultipart(class liboai::netimpl::components::Multipart &&)" (?SetMultipart@Session@netimpl@liboai@@AEAAX$$QEAVMultipart@components@23@@Z) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_mime_type referenced in function "private: void __cdecl liboai::netimpl::Session::SetMultipart(class liboai::netimpl::components::Multipart &&)" (?SetMultipart@Session@netimpl@liboai@@AEAAX$$QEAVMultipart@components@23@@Z) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_mime_data referenced in function "private: void __cdecl liboai::netimpl::Session::SetMultipart(class liboai::netimpl::components::Multipart &&)" (?SetMultipart@Session@netimpl@liboai@@AEAAX$$QEAVMultipart@components@23@@Z) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_mime_filedata referenced in function "private: void __cdecl liboai::netimpl::Session::SetMultipart(class liboai::netimpl::components::Multipart &&)" (?SetMultipart@Session@netimpl@liboai@@AEAAX$$QEAVMultipart@components@23@@Z) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_easy_escape referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl liboai::netimpl::CurlHolder::urlEncode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?urlEncode@CurlHolder@netimpl@liboai@@QEAA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV45@@Z) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_easy_unescape referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl liboai::netimpl::CurlHolder::urlDecode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?urlDecode@CurlHolder@netimpl@liboai@@QEAA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV45@@Z) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_free referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl liboai::netimpl::CurlHolder::urlDecode(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?urlDecode@CurlHolder@netimpl@liboai@@QEAA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV45@@Z) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_slist_append referenced in function "private: void __cdecl liboai::netimpl::Session::SetHeader(class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct liboai::netimpl::components::CaseInsensitiveCompare,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > const &)" (?SetHeader@Session@netimpl@liboai@@AEAAXAEBV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@UCaseInsensitiveCompare@components@netimpl@liboai@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@Z) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_slist_free_all referenced in function "public: virtual __cdecl liboai::netimpl::Session::~Session(void)" (??1Session@netimpl@liboai@@UEAA@XZ) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_version_info referenced in function "public: __cdecl liboai::netimpl::CurlHolder::CurlHolder(void)" (??0CurlHolder@netimpl@liboai@@QEAA@XZ) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_easy_strerror referenced in function "public: __cdecl liboai::netimpl::CurlHolder::CurlHolder(void)" (??0CurlHolder@netimpl@liboai@@QEAA@XZ) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_easy_init referenced in function "public: __cdecl liboai::netimpl::CurlHolder::CurlHolder(void)" (??0CurlHolder@netimpl@liboai@@QEAA@XZ) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_easy_setopt referenced in function "private: class liboai::Response __cdecl liboai::netimpl::Session::CompleteDownload(void)" (?CompleteDownload@Session@netimpl@liboai@@AEAA?AVResponse@3@XZ) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_easy_perform referenced in function "private: enum CURLcode __cdecl liboai::netimpl::Session::Perform(void)" (?Perform@Session@netimpl@liboai@@AEAA?AW4CURLcode@@XZ) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_easy_cleanup referenced in function "public: virtual __cdecl liboai::netimpl::CurlHolder::~CurlHolder(void)" (??1CurlHolder@netimpl@liboai@@UEAA@XZ) 1>netimpl.obj : error LNK2019: unresolved external symbol __imp_curl_easy_getinfo referenced in function "private: class liboai::Response __cdecl liboai::netimpl::Session::BuildResponseObject(void)" (?BuildResponseObject@Session@netimpl@liboai@@AEAA?AVResponse@3@XZ)
This is caused by you not linking to the cURL library. Your VS project needs to be linked either to (libcurl.dll + libcurl.lib) or libcurl.lib standalone, depending on whether you want cURL to be static or dynamic.
This can be done in Properties -> Linker -> Input -> Additional Dependencies.
I suggest looking into the VCPKG package manager for Windows, as it simplifies the process for linking packages (such as cURL) by a large amount.
Using VCPKG to install cURL worked. I finally managed to compile, Thank you for your help!
Now, I have an error when I run the test DALL-E code from the ReadMe, but that is a separate issue :)
Using VCPKG to install cURL worked. I finally managed to compile, Thank you for your help!
Now, I have an error when I run the test DALL-E code from the ReadMe, but that is a separate issue :)
The sample code in the main README is not exception safe. Refer to the documentation for proper exception safe code snippets.
Yes, I found that out after posting. It was because I didn't have the OPENAI_API_KEY environment variable set. It works now :)
Yes, I found that out after posting. It was because I didn't have the OPENAI_API_KEY environment variable set. It works now :)
No problem, enjoy the library.
Describe the bug
I just created an empty hello world project and included liboai, nlohmann-json and cURL to it.
When I try to compile it now, I get the following errors:
I must add that this is actually my first C++ project, so the error might be entirely on my side.
To Reproduce
Code snippets
OS
Windows 10
Library version
liboai 3.0.2