C++ ошибка при подключении библиотеки - fatal error: tgbot/tgbot.h: No such file or directory
Всем привет!
Недавно решил разобраться в c++ и переписать телеграмм бота с python на c++.
Скачал vcpkg - https://github.com/Microsoft/vcpkg/#quick-start-windows
через него установил tgbot - https://github.com/reo7sp/tgbot-cpp
Поставил начальный код
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <exception>
#include <string>
#include <vector>
#include <tgbot/tgbot.h>
using namespace std;
using namespace TgBot;
void createOneColumnKeyboard(const vector<string>& buttonStrings, ReplyKeyboardMarkup::Ptr& kb)
{
for (size_t i = 0; i < buttonStrings.size(); ++i) {
vector<KeyboardButton::Ptr> row;
KeyboardButton::Ptr button(new KeyboardButton);
button->text = buttonStrings[i];
row.push_back(button);
kb->keyboard.push_back(row);
}
}
void createKeyboard(const vector<vector<string>>& buttonLayout, ReplyKeyboardMarkup::Ptr& kb)
{
for (size_t i = 0; i < buttonLayout.size(); ++i) {
vector<KeyboardButton::Ptr> row;
for (size_t j = 0; j < buttonLayout[i].size(); ++j) {
KeyboardButton::Ptr button(new KeyboardButton);
button->text = buttonLayout[i][j];
row.push_back(button);
}
kb->keyboard.push_back(row);
}
}
int main() {
string token(getenv("6521141539:AAH7ZiWW5P6HWGAy-nBTI09Sftw1gE_u2vY"));
printf("Token: %s\n", token.c_str());
Bot bot(token);
ReplyKeyboardMarkup::Ptr keyboardOneCol(new ReplyKeyboardMarkup);
createOneColumnKeyboard({"Option 1", "Option 2", "Option 3"}, keyboardOneCol);
ReplyKeyboardMarkup::Ptr keyboardWithLayout(new ReplyKeyboardMarkup);
createKeyboard({
{"Dog", "Cat", "Mouse"},
{"Green", "White", "Red"},
{"On", "Off"},
{"Back"},
{"Info", "About", "Map", "Etc"}
}, keyboardWithLayout);
bot.getEvents().onCommand("start", [&bot, &keyboardOneCol](Message::Ptr message) {
bot.getApi().sendMessage(message->chat->id, "/start for one column keyboard\n/layout for a more complex keyboard", false, 0, keyboardOneCol);
});
bot.getEvents().onCommand("layout", [&bot, &keyboardWithLayout](Message::Ptr message) {
bot.getApi().sendMessage(message->chat->id, "/start for one column keyboard\n/layout for a more complex keyboard", false, 0, keyboardWithLayout);
});
bot.getEvents().onAnyMessage([&bot](Message::Ptr message) {
printf("User wrote %s\n", message->text.c_str());
if (StringTools::startsWith(message->text, "/start") || StringTools::startsWith(message->text, "/layout")) {
return;
}
bot.getApi().sendMessage(message->chat->id, "Your message is: " + message->text);
});
signal(SIGINT, [](int s) {
printf("SIGINT got\n");
exit(0);
});
try {
printf("Bot username: %s\n", bot.getApi().getMe()->username.c_str());
bot.getApi().deleteWebhook();
TgLongPoll longPoll(bot);
while (true) {
printf("Long poll started\n");
longPoll.start();
}
} catch (exception& e) {
printf("error: %s\n", e.what());
}
return 0;
}
Импорт библиотеки не подсвечивается как ошибка, но при запуске выдает ошибку:
main.cpp:8:10: fatal error: tgbot/tgbot.h: No such file or directory
8 | #include <tgbot/tgbot.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
Пути:
Vcpkg - D:\vcpkg
Библиотека - D:\vcpkg\installed\x64-windows\include\tgbot
w64devkit - D:\w64devkit
Мой проект - D:\Cod\practice\CPP-Telebot\main.cpp
В файле c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"D:/vcpkg/installed/x64-windows/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "D:/w64devkit/bin/g++.exe",
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4
}
В файле launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": true,
"cwd": "d:/Cod/practice/new",
"program": "d:/Cod/practice/new/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
В файле tasks.json:
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "D:/w64devkit/bin/g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
Помогите пожалуйста!
Использую vscode