D7EAD / liboai

A C++17 library to access the entire OpenAI API.
https://openai.com/api/
MIT License
340 stars 58 forks source link

error LNK2019: unresolved external symbol with brand new project #27

Closed divonelnc closed 1 year ago

divonelnc commented 1 year ago

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:

1>Blade.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl liboai::netimpl::Session::~Session(void)" (??1Session@netimpl@liboai@@UEAA@XZ) referenced in function "class liboai::Response __cdecl liboai::netimpl::Delete<class liboai::netimpl::components::Url &&,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> > > > > &&>(class liboai::netimpl::components::Url &&,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> > > > > &&)" (??$Delete@$$QEAVUrl@components@netimpl@liboai@@$$QEAV?$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@@@netimpl@liboai@@YA?AVResponse@1@$$QEAVUrl@components@01@$$QEAV?$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>Blade.obj : error LNK2019: unresolved external symbol "public: class liboai::Response __cdecl liboai::netimpl::Session::Get(void)" (?Get@Session@netimpl@liboai@@QEAA?AVResponse@3@XZ) referenced in function "class liboai::Response __cdecl liboai::netimpl::Get<class liboai::netimpl::components::Url &&,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> > > > > &&>(class liboai::netimpl::components::Url &&,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> > > > > &&)" (??$Get@$$QEAVUrl@components@netimpl@liboai@@$$QEAV?$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@@@netimpl@liboai@@YA?AVResponse@1@$$QEAVUrl@components@01@$$QEAV?$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>Blade.obj : error LNK2019: unresolved external symbol "public: class liboai::Response __cdecl liboai::netimpl::Session::Post(void)" (?Post@Session@netimpl@liboai@@QEAA?AVResponse@3@XZ) referenced in function "class liboai::Response __cdecl liboai::netimpl::Post<class liboai::netimpl::components::Url &&,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> > > > > &&>(class liboai::netimpl::components::Url &&,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> > > > > &&)" (??$Post@$$QEAVUrl@components@netimpl@liboai@@$$QEAV?$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@@@netimpl@liboai@@YA?AVResponse@1@$$QEAVUrl@components@01@$$QEAV?$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>Blade.obj : error LNK2019: unresolved external symbol "public: class liboai::Response __cdecl liboai::netimpl::Session::Delete(void)" (?Delete@Session@netimpl@liboai@@QEAA?AVResponse@3@XZ) referenced in function "class liboai::Response __cdecl liboai::netimpl::Delete<class liboai::netimpl::components::Url &&,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> > > > > &&>(class liboai::netimpl::components::Url &&,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> > > > > &&)" (??$Delete@$$QEAVUrl@components@netimpl@liboai@@$$QEAV?$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@@@netimpl@liboai@@YA?AVResponse@1@$$QEAVUrl@components@01@$$QEAV?$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>Blade.obj : error LNK2019: unresolved external symbol "private: void __cdecl liboai::netimpl::Session::SetOption(class liboai::netimpl::components::Url const &)" (?SetOption@Session@netimpl@liboai@@AEAAXAEBVUrl@components@23@@Z) referenced in function "void __cdecl liboai::netimpl::set_options<class liboai::netimpl::components::Url,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> > > > > >(class liboai::netimpl::Session &,class liboai::netimpl::components::Url &&,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> > > > > &&)" (??$set_options@VUrl@components@netimpl@liboai@@V?$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@@@netimpl@liboai@@YAXAEAVSession@01@$$QEAVUrl@components@01@$$QEAV?$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>Blade.obj : error LNK2019: unresolved external symbol "private: void __cdecl liboai::netimpl::Session::SetOption(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 &)" (?SetOption@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) referenced in function "void __cdecl liboai::netimpl::set_options<class liboai::netimpl::components::Url,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> > > > > >(class liboai::netimpl::Session &,class liboai::netimpl::components::Url &&,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> > > > > &&)" (??$set_options@VUrl@components@netimpl@liboai@@V?$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@@@netimpl@liboai@@YAXAEAVSession@01@$$QEAVUrl@components@01@$$QEAV?$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)

I must add that this is actually my first C++ project, so the error might be entirely on my side.

To Reproduce

  1. Create a new Visual studio C++ console command project
  2. Include the liboai, nlohmann-json and cURL librairies
  3. Attempt to compile

Code snippets

#include <iostream>
#include "liboai.h"

using namespace liboai;

int main()
{
    std::cout << "Hello World!\n";
}

OS

Windows 10

Library version

liboai 3.0.2

D7EAD commented 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?

divonelnc commented 1 year ago

I downloaded the source code, then added the include folder to the Additional include directories in Visual studio.

D7EAD commented 1 year ago

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.

divonelnc commented 1 year ago

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 :(

D7EAD commented 1 year ago

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.

image

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.

divonelnc commented 1 year ago

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)
D7EAD commented 1 year ago

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.

divonelnc commented 1 year ago

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 :) image

D7EAD commented 1 year ago

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 :) image

The sample code in the main README is not exception safe. Refer to the documentation for proper exception safe code snippets.

divonelnc commented 1 year ago

Yes, I found that out after posting. It was because I didn't have the OPENAI_API_KEY environment variable set. It works now :)

D7EAD commented 1 year ago

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.