Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error LNK2001: unresolved external symbol #319

Open
Amirhan-Taipovjan-Greatest-I opened this issue Oct 13, 2024 · 3 comments
Open

Error LNK2001: unresolved external symbol #319

Amirhan-Taipovjan-Greatest-I opened this issue Oct 13, 2024 · 3 comments

Comments

@Amirhan-Taipovjan-Greatest-I
Copy link

Amirhan-Taipovjan-Greatest-I commented Oct 13, 2024

Hello! I'm currently experiencing some Issues with InlineQuery...

My Code:

        bot.getEvents().onInlineQuery([&bot](const InlineQuery::Ptr& query) {

            std::vector<InlineQueryResult::Ptr> results;
            InlineQueryResultArticle::Ptr article(new InlineQueryResultArticle);

            auto text = InputTextMessageContent();
            text.messageText = "Inline Test";

            article->title = "Inline Title!";
            article->id = "1234";
            article->type = "article";
            results.push_back(article);

            bot.getApi().answerInlineQuery(query->id, results);
            });

Errors in Visual Studio:

1>main.obj : error LNK2001: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const TgBot::InlineQueryResultArticle::TYPE" (?TYPE@InlineQueryResultArticle@TgBot@@2V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@B).
1>main.obj : error LNK2001: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const TgBot::InputTextMessageContent::TYPE" (?TYPE@InputTextMessageContent@TgBot@@2V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@B).

I don't actually know if My Issue is about My code, to be honest... I tried do anything to fix that, but Issue still persists.
Used tgbot-cpp Version (via vcpkg): 1.7.3.

@Amirhan-Taipovjan-Greatest-I
Copy link
Author

Amirhan-Taipovjan-Greatest-I commented Oct 16, 2024

Even this Code:

        bot.getEvents().onInlineQuery([&bot](const InlineQuery::Ptr& query) {
            vector<InlineQueryResult::Ptr> lol;
            InlineQueryResultArticle::Ptr rofl(new InlineQueryResultArticle);

            auto testus = InputTextMessageContent();
            testus.messageText = "lol";
            
            rofl->title = "Inline Title!";
            rofl->id = "1234";
            lol.push_back(rofl);

            bot.getApi().answerInlineQuery(query->id, lol);
        });

And even reinstalling tgbot-cpp via vcpkg didn't help, the Issue still persists!

@Amirhan-Taipovjan-Greatest-I
Copy link
Author

Temporary fix for this Issue is:

Putting this Piece of Code in your .cpp:

using namespace std;
using namespace TgBot;

const string InlineQueryResultCachedAudio::TYPE = "audio";
const string InlineQueryResultCachedDocument::TYPE = "document";
const string InlineQueryResultCachedGif::TYPE = "gif";
const string InlineQueryResultCachedMpeg4Gif::TYPE = "mpeg4_gif";
const string InlineQueryResultCachedPhoto::TYPE = "photo";
const string InlineQueryResultCachedSticker::TYPE = "sticker";
const string InlineQueryResultCachedVideo::TYPE = "video";
const string InlineQueryResultCachedVoice::TYPE = "voice";

const string InlineQueryResultArticle::TYPE = "article";
const string InlineQueryResultAudio::TYPE = "audio";
const string InlineQueryResultContact::TYPE = "contact";
const string InlineQueryResultGame::TYPE = "game";
const string InlineQueryResultDocument::TYPE = "document";
const string InlineQueryResultGif::TYPE = "gif";
const string InlineQueryResultLocation::TYPE = "location";
const string InlineQueryResultMpeg4Gif::TYPE = "mpeg4_gif";
const string InlineQueryResultPhoto::TYPE = "photo";
const string InlineQueryResultVenue::TYPE = "venue";
const string InlineQueryResultVideo::TYPE = "video";
const string InlineQueryResultVoice::TYPE = "voice";
const string InputTextMessageContent::TYPE = "text";
const string InputLocationMessageContent::TYPE = "location";
const string InputVenueMessageContent::TYPE = "venue";
const string InputContactMessageContent::TYPE = "contact";
const string InputInvoiceMessageContent::TYPE = "invoice";

@Amirhan-Taipovjan-Greatest-I
Copy link
Author

Amirhan-Taipovjan-Greatest-I commented Oct 17, 2024

Couldn't solve some more Errors and decided to use #113 Code Piece... yep, it worked as intended, with My Addendum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant