reo7sp / tgbot-cpp

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

Api: link error #88

Open rvalvekar opened 5 years ago

rvalvekar commented 5 years ago

error: undefined reference to `TgBot::Api::Api(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)'

I have been linking libraries as per given on github. The Samples work just fine, when i try to implement in other programs, the program gives error.

Plus the library has a lot of issues with boost and gateway time outs.

zamazan4ik commented 4 years ago

@rvalvekar do you have any of the described above problem with the latest TgBot from master?

milkpirate commented 2 years ago

@rvalvekar Yes, I do:

$ cmake --build . --clean-first 
[ 14%] Building CXX object CMakeFiles/main.dir/src/main.cpp.o
[ 28%] Building CXX object CMakeFiles/main.dir/src/lib/TgAuthBot/TgAuthBot.cpp.o
[ 42%] Linking CXX executable bin/main
/usr/bin/ld: CMakeFiles/main.dir/src/lib/TgAuthBot/TgAuthBot.cpp.o: in function `TgAuthBot::TgAuthBot(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long, unsigned int)':
TgAuthBot.cpp:(.text._ZN9TgAuthBotC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEElj+0xd7): undefined reference to `TgBot::Bot::Bot(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, TgBot::HttpClient const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: CMakeFiles/main.dir/src/lib/TgAuthBot/TgAuthBot.cpp.o: in function `TgAuthBot::isApproved(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
TgAuthBot.cpp:(.text._ZN9TgAuthBot10isApprovedERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x713): undefined reference to `TgBot::Api::sendMessage(long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, int, std::shared_ptr<TgBot::GenericReply>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) const'
/usr/bin/ld: TgAuthBot.cpp:(.text._ZN9TgAuthBot10isApprovedERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x8d3): undefined reference to `TgBot::TgLongPoll::TgLongPoll(TgBot::Bot const&, int, int, std::shared_ptr<std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > const&)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/main.dir/build.make:113: bin/main] Error 1
make[1]: *** [CMakeFiles/Makefile2:85: CMakeFiles/main.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

oddly enough including #include <spdlog/spdlog.h> does fix this, but since I have other options I would like to get rid of this lib.

milkpirate commented 2 years ago

Hey guys, I had similar issues and I fiddled a lot, but this seemed to help:

$ conan profile update settings.compiler.libcxx=libstdc++11 default

Dont know to what is was set before, maybe just libstdc++ but this made the change for me. You might want to do a

$ conan install --update .

afterwards :man_shrugging:

This gave me the hint: https://github.com/reo7sp/tgbot-cpp/issues/14#issuecomment-872338093