olrea / openai-cpp

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

Errors when compiling under Windows #4

Open VicKov1975 opened 1 year ago

VicKov1975 commented 1 year ago

I have installed libcurl on Windows (in D:/curl) by following your instructions after I ran into "You might have difficulties handling libcurl where CMake throws Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR)."

So I have copied curl.lib and libcurl.dll from the lib64/ and bin64/ folders of the libcurl-7.48.0-WinSSL-zlib-x86-x64.zip to D:/curl/lib.

Then I ran CMake: cmake .. -DCMAKE_GENERATOR_PLATFORM=x64 -DCURL_LIBRARY=D:/curl/lib/curl.lib -DCURL_INCLUDE_DIR=D:/curl/include

Everything went fine.

But when I ran: cmake --build .

I got these errors:

00-showcase.obj : error LNK2019: unresolved external symbol imp_curl_mime_free referenced in function "public: cdec l openai::_detail::Session::~Session(void)" (??1Session@_detail@openai@@QEAA@XZ) [D:\openai-cpp\build\examples\00-showc ase.vcxproj] D:\openai-cpp\build\examples\Debug\00-showcase.exe : fatal error LNK1120: 1 unresolved externals [D:\openai-cpp\build\e xamples\00-showcase.vcxproj] 01-model.obj : error LNK2019: unresolved external symbol imp_curl_mime_free referenced in function "public: cdecl o penai::_detail::Session::~Session(void)" (??1Session@_detail@openai@@QEAA@XZ) [D:\openai-cpp\build\examples\01-model.vc xproj] D:\openai-cpp\build\examples\Debug\01-model.exe : fatal error LNK1120: 1 unresolved externals [D:\openai-cpp\build\exam ples\01-model.vcxproj] 02-completion.obj : error LNK2019: unresolved external symbol imp_curl_mime_free referenced in function "public: cd ecl openai::_detail::Session::~Session(void)" (??1Session@_detail@openai@@QEAA@XZ) [D:\openai-cpp\build\examples\02-com pletion.vcxproj] D:\openai-cpp\build\examples\Debug\02-completion.exe : fatal error LNK1120: 1 unresolved externals [D:\openai-cpp\build \examples\02-completion.vcxproj] 03-edit.obj : error LNK2019: unresolved external symbol imp_curl_mime_free referenced in function "public: cdecl op enai::_detail::Session::~Session(void)" (??1Session@_detail@openai@@QEAA@XZ) [D:\openai-cpp\build\examples\03-edit.vcxp roj] D:\openai-cpp\build\examples\Debug\03-edit.exe : fatal error LNK1120: 1 unresolved externals [D:\openai-cpp\build\examp les\03-edit.vcxproj] 04-image.obj : error LNK2019: unresolved external symbol imp_curl_mime_free referenced in function "public: cdecl o penai::_detail::Session::~Session(void)" (??1Session@_detail@openai@@QEAA@XZ) [D:\openai-cpp\build\examples\04-image.vc xproj] D:\openai-cpp\build\examples\Debug\04-image.exe : fatal error LNK1120: 1 unresolved externals [D:\openai-cpp\build\exam ples\04-image.vcxproj] 05-embedding.obj : error LNK2019: unresolved external symbol imp_curl_mime_free referenced in function "public: cde cl openai::_detail::Session::~Session(void)" (??1Session@_detail@openai@@QEAA@XZ) [D:\openai-cpp\build\examples\05-embe dding.vcxproj] D:\openai-cpp\build\examples\Debug\05-embedding.exe : fatal error LNK1120: 1 unresolved externals [D:\openai-cpp\build\ examples\05-embedding.vcxproj] 06-file.obj : error LNK2019: unresolved external symbol imp_curl_mime_init referenced in function "public: void cde cl openai::_detail::Session::setMultiformPart(class std::basic_string<char,struct std::char_traits,class std::all ocator > const &,class std::basic_string<char,struct std::char_traits,class std::allocator > const &) " (?setMultiformPart@Session@_detail@openai@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z) [D:\openai-cpp\build\examples\06-file.vcxproj] 06-file.obj : error LNK2019: unresolved external symbol imp_curl_mime_free referenced in function "public: cdecl op enai::_detail::Session::~Session(void)" (??1Session@_detail@openai@@QEAA@XZ) [D:\openai-cpp\build\examples\06-file.vcxp roj] 06-file.obj : error LNK2019: unresolved external symbol imp_curl_mime_addpart referenced in function "public: void cdecl openai::_detail::Session::setMultiformPart(class std::basic_string<char,struct std::char_traits,class std:: allocator > const &,class std::basic_string<char,struct std::char_traits,class std::allocator > const &)" (?setMultiformPart@Session@_detail@openai@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0 @Z) [D:\openai-cpp\build\examples\06-file.vcxproj] 06-file.obj : error LNK2019: unresolved external symbol imp_curl_mime_name referenced in function "public: void cde cl openai::_detail::Session::setMultiformPart(class std::basic_string<char,struct std::char_traits,class std::all ocator > const &,class std::basic_string<char,struct std::char_traits,class std::allocator > const &) " (?setMultiformPart@Session@_detail@openai@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z) [D:\openai-cpp\build\examples\06-file.vcxproj] 06-file.obj : error LNK2019: unresolved external symbol imp_curl_mime_data referenced in function "public: void cde cl openai::_detail::Session::setMultiformPart(class std::basic_string<char,struct std::char_traits,class std::all ocator > const &,class std::basic_string<char,struct std::char_traits,class std::allocator > const &) " (?setMultiformPart@Session@_detail@openai@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@0@Z) [D:\openai-cpp\build\examples\06-file.vcxproj] 06-file.obj : error LNK2019: unresolved external symbol imp_curl_mimefiledata referenced in function "public: void _cdecl openai::_detail::Session::setMultiformPart(class std::basic_string<char,struct std::char_traits,class std: :allocator > const &,class std::basic_string<char,struct std::char_traits,class std::allocator > cons t &)" (?setMultiformPart@Session@_detail@openai@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ 0@Z) [D:\openai-cpp\build\examples\06-file.vcxproj] D:\openai-cpp\build\examples\Debug\06-file.exe : fatal error LNK1120: 6 unresolved externals [D:\openai-cpp\build\examp les\06-file.vcxproj] 07-fine-tune.obj : error LNK2019: unresolved external symbol imp_curl_mime_free referenced in function "public: cde cl openai::_detail::Session::~Session(void)" (??1Session@_detail@openai@@QEAA@XZ) [D:\openai-cpp\build\examples\07-fine -tune.vcxproj] D:\openai-cpp\build\examples\Debug\07-fine-tune.exe : fatal error LNK1120: 1 unresolved externals [D:\openai-cpp\build\ examples\07-fine-tune.vcxproj] 09-instances.obj : error LNK2019: unresolved external symbol imp_curl_mime_free referenced in function "public: __cde cl openai::_detail::Session::~Session(void)" (??1Session@_detail@openai@@QEAA@XZ) [D:\openai-cpp\build\examples\09-inst ances.vcxproj] D:\openai-cpp\build\examples\Debug\09-instances.exe : fatal error LNK1120: 1 unresolved externals [D:\openai-cpp\build\ examples\09-instances.vcxproj]

coin-au-carre commented 1 year ago

I am not sure I understand your issue. It seems you have succeeded right ? I suppose that the libraries are not in your PATH and that is why cmake --build . cannot work simply ? If that is the case, I will refer to your issue for users on Windows that can be helpful thanks.