olrea / openai-cpp

OpenAI C++ is a community-maintained library for the Open AI API
https://openai.com/api/
MIT License
195 stars 66 forks source link

Visual Studio Generate and Linking Error: openai.hpp #18

Closed gjxo12 closed 1 year ago

gjxo12 commented 1 year ago

Hello,

I am trying to generator this project with cmake and build it with VS solution.

For the CURL package, set it to the manual path and the command is as follows. cmake -B build -DCMAKE_GENERATOR_PLATFORM=x64 -DCURL_LIBRARY=C:[path]\curl-8.1.0_1-win64-mingw\curl-8.1.0_1-win64-mingw\lib\libcurl.a -DCURL_INCLUDE_DIR=C:[path] \curl-8.1.0_1-win64-mingw\curl-8.1.0_1-win64-mingw\include

Visual Studio 02-completion project's Linker Options -> Additional Dependencies has a CURL library path and C/C++ Options has confirmed that the include path with openai.hpp is set.

Compiles in this situation, but a linking error occurs. Cannot find xrefs for hpp files.

Even if I add the corresponding hpp file to add_executable in CMakeLists or put this hpp file in target_include_directorties, the linking error still occurs.


2>02-completion.obj : error LNK2019: __imp_curl_global_init"public: void __cdecl openai::_detail::Session::initCurl(void)" (?initCurl@Session@_detail@openai@@QEAAXXZ) 함수에서 참조되는 확인할 수 없는 외부 기호
2>02-completion.obj : error LNK2019: __imp_curl_global_cleanup"public: __cdecl openai::_detail::Session::~Session(void)" (??1Session@_detail@openai@@QEAA@XZ) 함수에서 참조되는 확인할 수 없는 외부 기호
2>02-completion.obj : error LNK2019: __imp_curl_slist_append"public: struct openai::_detail::Response __cdecl openai::_detail::Session::makeRequest(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?makeRequest@Session@_detail@openai@@QEAA?AUResponse@23@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 함수에서 참조되는 확인할 수 없는 외부 기호
2>02-completion.obj : error LNK2019: __imp_curl_easy_strerror"public: struct openai::_detail::Response __cdecl openai::_detail::Session::makeRequest(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?makeRequest@Session@_detail@openai@@QEAA?AUResponse@23@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 함수에서 참조되는 확인할 수 없는 외부 기호
2>02-completion.obj : error LNK2019: __imp_curl_easy_init"public: void __cdecl openai::_detail::Session::initCurl(void)" (?initCurl@Session@_detail@openai@@QEAAXXZ) 함수에서 참조되는 확인할 수 없는 외부 기호
2>02-completion.obj : error LNK2019: __imp_curl_easy_setopt"public: void __cdecl openai::_detail::Session::ignoreSSL(void)" (?ignoreSSL@Session@_detail@openai@@QEAAXXZ) 함수에서 참조되는 확인할 수 없는 외부 기호
2>02-completion.obj : error LNK2019: __imp_curl_easy_perform"public: struct openai::_detail::Response __cdecl openai::_detail::Session::makeRequest(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?makeRequest@Session@_detail@openai@@QEAA?AUResponse@23@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) 함수에서 참조되는 확인할 수 없는 외부 기호
2>02-completion.obj : error LNK2019: __imp_curl_easy_cleanup"public: __cdecl openai::_detail::Session::~Session(void)" (??1Session@_detail@openai@@QEAA@XZ) 함수에서 참조되는 확인할 수 없는 외부 기호
2>D:\personal\openai-cpp\build\examples\Debug\02-completion.exe : fatal error LNK1120: 9개의 확인할 수 없는 외부 참조입니다.```
gjxo12 commented 1 year ago

Oh, I'm Sorry I think my local CURL libaray / include is wrong.

I'll fix them later Thanks