I have encountered with link error while building example app, this one (https://github.com/tdlib/td/blob/master/example/cpp/td_example.cpp) I created project in Qt creator and added td_example.cpp to project. Also previously I have build 32x Td library from sources using this instruction https://tdlib.github.io/td/build.html?language=C%2B%2B .
Td artifacts located in this path K:\QtProjects\Telegram\TelegramDependency\td\tdlib , here is located 3 folders (bin, include and lib).
in bin folder located 4 .dll files (libcrypto-1_1.dll, libssl-1_1.dll, tdjson.dll, zlibd1.dll)
in lib folder located (tdactor.lib, tdapi.lib, tdclient.lib, tdcore.lib, tddb.lib, tdjson.lib, tdjson_private.lib, tdjson_static.lib, tdnet.lib, tdsqlite.lib, tdutils.lib)
My project located under this path K:\QtProjects\Telegram\TelegramTestAPP
in folder TelegramTestAPP i have .pro file with such content.
QT += quick
CONFIG += c++20
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
Logger.cpp \
main.cpp \
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
HEADERS += \
Logger.h \
td_example.h
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltdjson
INCLUDEPATH += $$PWD/../TelegramDependency/td/tdlib/include
DEPENDPATH += $$PWD/../TelegramDependency/td/tdlib/include
i removed main function from td_example.cpp and renamed to td_example.h , after that I included this header file and called it from main.cpp inside main function
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "td_example.h"
int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty(QStringLiteral("CLogger"), &Logger::GetInstance());
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
TdExample example;
example.loop();
return app.exec();
}
So the question is, why i get link error example of error
main.obj:-1: error: LNK2019: unresolved external symbol "public: __thiscall td::td_api::tdlibParameters::tdlibParameters(void)" (??0tdlibParameters@td_api@td@@QAE@XZ) referenced in function "class td::tl::unique_ptr<class td::td_api::tdlibParameters> __cdecl td::td_api::make_object<class td::td_api::tdlibParameters>(void)" (??$make_object@VtdlibParameters@td_api@td@@$$V@td_api@td@@YA?AV?$unique_ptr@VtdlibParameters@td_api@td@@@tl@1@XZ)
compiler: Microsoft Visual C++ Complier 14.0 (amd64_x86) I also copied all .dll from bin folder to debug folder (TelegramTestAPP/build/debug)
EDIT Added all static libraries to .pro file
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltdapi
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltdutils
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltdclient
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltdnet
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltdcore
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltdsqlite
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltdactor
win32: LIBS += -L'$$PWD/../TelegramDependency/td/tdlib/lib/' -ltddb
INCLUDEPATH += $$PWD/../TelegramDependency/td/tdlib/include
DEPENDPATH += $$PWD/../TelegramDependency/td/tdlib/include
win32: PRE_TARGETDEPS += $$PWD/../TelegramDependency/td/tdlib/lib/tdcore.lib
win32: PRE_TARGETDEPS += $$PWD/../TelegramDependency/td/tdlib/lib/tdapi.lib
win32: PRE_TARGETDEPS += $$PWD/../TelegramDependency/td/tdlib/lib/tdclient.lib
win32: PRE_TARGETDEPS += $$PWD/../TelegramDependency/td/tdlib/lib/tdutils.lib
win32: PRE_TARGETDEPS += $$PWD/../TelegramDependency/td/tdlib/lib/tdactor.lib
win32: PRE_TARGETDEPS += $$PWD/../TelegramDependency/td/tdlib/lib/tddb.lib
win32: PRE_TARGETDEPS += $$PWD/../TelegramDependency/td/tdlib/lib/tdnet.lib
win32: PRE_TARGETDEPS += $$PWD/../TelegramDependency/td/tdlib/lib/tdsqlite.lib
win32: LIBS += -L'C:/Program Files (x86)/OpenSSL-Win32/lib/VC/' -llibcrypto32MDd
win32: LIBS += -L'C:/Program Files (x86)/OpenSSL-Win32/lib/VC/' -llibssl32MDd
INCLUDEPATH += 'C:/Program Files (x86)/OpenSSL-Win32/include'
DEPENDPATH += 'C:/Program Files (x86)/OpenSSL-Win32/include'
new Errors (compiler gcc 32 bit)
error: undefined reference to `td::ClientManager::execute(td::tl::unique_ptr<td::td_api::Function>&&)'
debug/TdController.o: In function `ZN12TdControllerC2Ev':
error: undefined reference to `td::td_api::setLogVerbosityLevel::setLogVerbosityLevel(int)'
debug/TdController.o: In function `ZN2td6td_api11make_objectINS0_20setLogVerbosityLevelEJiEEENS_2tl10unique_ptrIT_EEDpOT0_':
error: undefined reference to `vtable for td::td_api::setLogVerbosityLevel'
debug/TdController.o: In function `ZN2td6td_api20setLogVerbosityLevel
D1Ev':