reo7sp / tgbot-cpp

C++ library for Telegram bot API
http://reo7sp.github.io/tgbot-cpp
MIT License
1.01k stars 246 forks source link

Hi everyone, i have erorrs on compilation of test, i have boost,openssl,curl but how to add this library currectly ? #135

Closed ummdd closed 4 years ago

ummdd commented 4 years ago

Firstly Sorry of my english, i have this errors: Ошибка LNK2019 ссылка на неразрешенный внешний символ "public: static class std::shared_ptr __cdecl TgBot::InputFile::fromFile(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 &)" (?fromFile@InputFile@TgBot@@SA?AV?$shared_ptr@VInputFile@TgBot@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@4@0@Z) в функции "public: void __cdecl ::operator()(class std::shared_ptr)const " (??R@@QEBAXV?$shared_ptr@VMessage@TgBot@@@std@@@Z) testForCPR C:\Users\acer\source\repos\testForCPR\testForCPR\testForCPR.obj 1

egorpugin commented 4 years ago

Hi,

How do you link this library? Are you using cmake to generate VS project?


Build tgbot library statically, it should help. InputFile is not exported indeed.

egorpugin commented 4 years ago

I've added missing TGBOT_API. But this might not help you until you try static build. https://github.com/reo7sp/tgbot-cpp/commit/a79166516734d965032b5e94b66f1aae9f493424

ummdd commented 4 years ago

i just adding include path to my project in visual studio

ummdd commented 4 years ago

when I try to compile it gives an error such $ cmake . -- Building for: Visual Studio 16 2019 -- The C compiler identification is MSVC 19.24.28314.0 -- The CXX compiler identification is MSVC 19.24.28314.0 -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Looking for pthread.h -- Looking for pthread.h - not found -- Found Threads: TRUE CMake Error at D:/cmake-3.16.2-win64-x64/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message): Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.11") Call Stack (most recent call first): D:/cmake-3.16.2-win64-x64/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE) D:/cmake-3.16.2-win64-x64/share/cmake-3.16/Modules/FindZLIB.cmake:115 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:40 (find_package)

zamazan4ik commented 4 years ago

@ummdd you should provide all required dependencies to your application. You can do it manually (but it's not recommended way).

I suggest you to use Conan dependency manager (https://docs.conan.io/en/latest/). Then try to use tgbot-cpp library from Conan (e.g. you can use my package: tgbot-cpp/1.1@zamazan4ik/testing).

I hope it will help you.

brunolapastina commented 4 years ago

@ummdd I have the same problem. Under ubuntu you can fiz this by installing libz sudo apt-get install zlib1g-dev

After that I also had to install libcurl sudo apt-get install libcurl14-openssl-dev

That fixed for me

CyrusDe commented 4 years ago

@ZaMaZaN4iK

I suggest you to use Conan dependency manager (https://docs.conan.io/en/latest/). Then try to use tgbot-cpp library from Conan (e.g. you can use my package: tgbot-cpp/1.1@zamazan4ik/testing).

Your package doesn't seem to exist. Is there anything i'm missing here? I'm using the command conan install tgbot-cpp/1.1@zamazan4ik/testing

zamazan4ik commented 4 years ago

@CyrusDe I think you just forgot about adding my remote for using this package. My conan package for tgbot-cpp is available here: https://bintray.com/zamazan4ik/conan/tgbot-cpp%3Azamazan4ik

Before conan install tgbot-cpp/1.1@zamazan4ik/testing you need add my remote with the following command: conan remote add zamazan4ik https://api.bintray.com/conan/zamazan4ik/conan

Hope it'll help you.

CyrusDe commented 4 years ago

@ZaMaZaN4iK Tried the commands and it installed the dependencies but the tgbot files seem to have problems. Conan produces this log:

https://pastebin.com/DXyT029t

Also trying to build it just using Cmake throws this error: "Error in configuration process, project files may be invalid.

zamazan4ik commented 4 years ago

I don't know why but CMake tries to use pthread.h on Windows. Didn't meet such problems before (since I don't use Windows).

egorpugin commented 4 years ago

@CyrusDe You could try my fork https://github.com/egorpugin/tgbot with other package manager (SW).