Can't link libzt and ZeroTierSockets.h in QtCreator Windows 10

Hi, I’m really new to C++ and need some help.

I’m trying to follow the ZeroTierSockets Tutorial (ZeroTier Sockets | ZeroTier Documentation) but I keep getting the error : “LNK2019: unresolved external symbol __imp_zts_node_start referenced in function main”.

I’m using QtCreator 6.0.1 on Windows 10 64-bit. Following the documentation here (https://github.com/zerotier/libzt), I’ve built it from source and have a libzt.dll and libzt.lib files. On my .pro file, I’ve added the libraries as per Qt’s instructions on linking external libraries. I’ve tried linking the libraries dynamically and statically, but to no avail.

Here’s a snippet of my Qt .pro file to link against libzt.lib dynamically :

QT       += core gui network

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# 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 += \
    main.cpp \

HEADERS += \

FORMS +=

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

DISTFILES += \

SUBDIRS += \


win32: LIBS += -L$$PWD/zerotier/libzt/dist/win-x64-host-debug/lib/ -llibzt

INCLUDEPATH += $$PWD/zerotier/libzt/dist/win-x64-host-debug $$PWD/zerotier/libzt/src $$PWD/zerotier/libzt/include
DEPENDPATH += $$PWD/zerotier/libzt/dist/win-x64-host-debug $$PWD/zerotier/libzt/src $$PWD/zerotier/libzt/include

Here’s a snippet of my code to follow the ZeroTierSockets tutorial :

#include "zerotier/libzt/include/ZeroTierSockets.h"


int main(int argc, char *argv[])
{

    qInfo() << "test";

    zts_node_start();

}

Here’s a snippet of the error output :

main.obj : error LNK2019: unresolved external symbol __imp_zts_node_start referenced in function main
debug\Test.exe : fatal error LNK1120: 1 unresolved externals

I’ve searched everywhere online but found no promising directions other than fiddling with the preprocessor directives ZeroTierSockets.h, specifically the __declspec(dllimport) / __declspec(dllexport) lines.

I’m unsure what I’m doing wrong so please help. Let me know if I should provide further information.

Thanks in advance!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.