'LNK 2001 and I'm trying to include the ProtoBuf library
I'm trying to build a 2016 project (Ricochet) on Qt 5.15 (MSVC 2019). And I get these errors:

Complains about Protobuf(3.6.0) library files Somehow I collected the libraries myself through the same Qt. Please help, I've been struggling with this problem for 2 days now.
For reference: Qt 5.15.0 + MSVC 2019 + WIndows 10
.pro file project
lessThan(QT_MAJOR_VERSION,5)|lessThan(QT_MINOR_VERSION,1) {
error("Qt 5.1 or greater is required. You can build your own, or get the SDK at https://qt-project.org/downloads")
}
TARGET = ricochet
TEMPLATE = app
QT += core gui network quick widgets
CONFIG += c++17
CONFIG += gnu++17
VERSION = 1.1.4
# Use CONFIG+=no-hardened to disable compiler hardening options
!CONFIG(no-hardened) {
CONFIG += hardened
include(hardened.pri)
}
# Pass DEFINES+=RICOCHET_NO_PORTABLE for a system-wide installation
CONFIG(release,debug|release):DEFINES += QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT
contains(DEFINES, RICOCHET_NO_PORTABLE) {
unix:!macx {
target.path = /usr/bin
shortcut.path = /usr/share/applications
shortcut.files = src/ricochet.desktop
icon.path = /usr/share/icons/hicolor/48x48/apps/
icon.files = icons/ricochet.png
scalable_icon.path = /usr/share/icons/hicolor/scalable/apps/
scalable_icon.files = icons/ricochet.svg
INSTALLS += target shortcut icon scalable_icon
QMAKE_CLEAN += contrib/usr.bin.ricochet
contains(DEFINES, APPARMOR) {
apparmor_profile.extra = cp -f $${_PRO_FILE_PWD_}/contrib/usr.bin.ricochet-apparmor $${_PRO_FILE_PWD_}/contrib/usr.bin.ricochet
apparmor_profile.files = contrib/usr.bin.ricochet
QMAKE_CLEAN += contrib/usr.bin.ricochet
!isEmpty(APPARMORDIR) {
apparmor_profile.path = $${APPARMORDIR}/
} else {
apparmor_profile.path = /etc/apparmor.d/
}
INSTALLS += apparmor_profile
}
exists(tor) {
message(Adding bundled Tor to installations)
bundletor.path = /usr/lib/ricochet/tor/
bundletor.files = tor/*
INSTALLS += bundletor
DEFINES += BUNDLED_TOR_PATH=\\\"/usr/lib/ricochet/tor/\\\"
}
}
}
macx {
CONFIG += bundle force_debug_plist
QT += macextras
# Qt 5.4 introduces a bug that breaks QMAKE_INFO_PLIST when qmake has a relative path.
# Work around by copying Info.plist directly.
greaterThan(QT_MAJOR_VERSION,5)|greaterThan(QT_MINOR_VERSION,4) {
QMAKE_INFO_PLIST = src/Info.plist
} else:equals(QT_MAJOR_VERSION,5):lessThan(QT_MINOR_VERSION,4) {
QMAKE_INFO_PLIST = src/Info.plist
} else {
CONFIG += no_plist
QMAKE_POST_LINK += cp $${_PRO_FILE_PWD_}/src/Info.plist $${OUT_PWD}/$${TARGET}.app/Contents/;
}
exists(tor) {
# Copy the entire tor/ directory, which should contain tor/tor (the binary itself)
QMAKE_POST_LINK += cp -R $${_PRO_FILE_PWD_}/tor $${OUT_PWD}/$${TARGET}.app/Contents/MacOS/;
}
icons.files = icons/Ricochet.icns
icons.path = Contents/Resources/
QMAKE_BUNDLE_DATA += icons
}
CONFIG += debug_and_release
# Create a pdb for release builds as well, to enable debugging
win32-msvc2008|win32-msvc2010 {
QMAKE_CXXFLAGS_RELEASE += /Zi
QMAKE_LFLAGS_RELEASE += /DEBUG /OPT:REF,ICF
}
INCLUDEPATH += src
win32|mac {
# For mac, this is necessary because homebrew does not link openssl .pc to
# /usr/local/lib/pkgconfig (presumably because it used to be a system
# package).
#
# Unfortunately, it is no longer really a system package, and we really
# need to know where it is.
isEmpty(OPENSSLDIR): error(You must pass OPENSSLDIR=path/to/openssl to qmake on this platform)
}
unix {
!isEmpty(OPENSSLDIR) {
INCLUDEPATH += $${OPENSSLDIR}/include
LIBS += -L$${OPENSSLDIR}/lib -lcrypto
} else {
CONFIG += link_pkgconfig
PKGCONFIG += libcrypto
}
}
win32 {
INCLUDEPATH += $${OPENSSLDIR}/include
INCLUDEPATH += $${PROTOBUFDIR}
# win32-g++ {
# LIBS += -L$${OPENSSLDIR}/lib -lcrypto
# } else {
# LIBS += -L$${OPENSSLDIR}/lib -llibeay32
# }
LIBS += "C:/Users/vesto/Documents/Stealer/libs/libcrypto.lib"
# required by openssl
LIBS += -luser32 -lgdi32 -ladvapi32
}
# Exclude unneeded plugins from static builds
QTPLUGIN.playlistformats = -
QTPLUGIN.imageformats = -
QTPLUGIN.printsupport = -
QTPLUGIN.mediaservice = -
# Include Linux input plugins, which are missing by default, to provide complex input support. See issue #60.
unix:!macx:QTPLUGIN.platforminputcontexts = composeplatforminputcontextplugin ibusplatforminputcontextplugin
DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII
SOURCES += src/main.cpp \
src/ui/MainWindow.cpp \
src/ui/ContactsModel.cpp \
src/tor/TorControl.cpp \
src/tor/TorControlSocket.cpp \
src/tor/TorControlCommand.cpp \
src/tor/ProtocolInfoCommand.cpp \
src/tor/AuthenticateCommand.cpp \
src/tor/SetConfCommand.cpp \
src/tor/AddOnionCommand.cpp \
src/utils/StringUtil.cpp \
src/core/ContactsManager.cpp \
src/core/ContactUser.cpp \
src/tor/GetConfCommand.cpp \
src/tor/HiddenService.cpp \
src/utils/CryptoKey.cpp \
src/utils/SecureRNG.cpp \
src/core/OutgoingContactRequest.cpp \
src/core/IncomingRequestManager.cpp \
src/core/ContactIDValidator.cpp \
src/core/UserIdentity.cpp \
src/core/IdentityManager.cpp \
src/core/ConversationModel.cpp \
src/tor/TorProcess.cpp \
src/tor/TorManager.cpp \
src/tor/TorSocket.cpp \
src/ui/LinkedText.cpp \
src/utils/Settings.cpp \
src/utils/PendingOperation.cpp \
src/ui/LanguagesModel.cpp
HEADERS += src/ui/MainWindow.h \
src/ui/ContactsModel.h \
src/tor/TorControl.h \
src/tor/TorControlSocket.h \
src/tor/TorControlCommand.h \
src/tor/ProtocolInfoCommand.h \
src/tor/AuthenticateCommand.h \
src/tor/SetConfCommand.h \
src/tor/AddOnionCommand.h \
src/utils/StringUtil.h \
src/core/ContactsManager.h \
src/core/ContactUser.h \
src/tor/GetConfCommand.h \
src/tor/HiddenService.h \
src/utils/CryptoKey.h \
src/utils/SecureRNG.h \
src/core/OutgoingContactRequest.h \
src/core/IncomingRequestManager.h \
src/core/ContactIDValidator.h \
src/core/UserIdentity.h \
src/core/IdentityManager.h \
src/core/ConversationModel.h \
src/tor/TorProcess.h \
src/tor/TorProcess_p.h \
src/tor/TorManager.h \
src/tor/TorSocket.h \
src/ui/LinkedText.h \
src/utils/Settings.h \
src/utils/PendingOperation.h \
src/ui/LanguagesModel.h
SOURCES += src/protocol/Channel.cpp \
src/protocol/ControlChannel.cpp \
src/protocol/Connection.cpp \
src/protocol/OutboundConnector.cpp \
src/protocol/AuthHiddenServiceChannel.cpp \
src/protocol/ChatChannel.cpp \
src/protocol/ContactRequestChannel.cpp
HEADERS += src/protocol/Channel.h \
src/protocol/Channel_p.h \
src/protocol/ControlChannel.h \
src/protocol/Connection.h \
src/protocol/Connection_p.h \
src/protocol/OutboundConnector.h \
src/protocol/AuthHiddenServiceChannel.h \
src/protocol/ChatChannel.h \
src/protocol/ContactRequestChannel.h
include(protobuf.pri)
PROTOS += src/protocol/ControlChannel.proto \
src/protocol/AuthHiddenService.proto \
src/protocol/ChatChannel.proto \
src/protocol/ContactRequestChannel.proto
# QML
RESOURCES += src/ui/qml/qml.qrc \
icons/icons.qrc \
sounds/sounds.qrc
win32:RC_ICONS = icons/ricochet.ico
OTHER_FILES += src/ui/qml/*
lupdate_only {
SOURCES += src/ui/qml/*.qml
}
# Translations
TRANSLATIONS += \
ricochet_en \
ricochet_it \
ricochet_es \
ricochet_da \
ricochet_pl \
ricochet_pt_BR \
ricochet_de \
ricochet_bg \
ricochet_cs \
ricochet_fi \
ricochet_fr \
ricochet_ru \
ricochet_uk \
ricochet_tr \
ricochet_nl_NL \
ricochet_fil_PH \
ricochet_sv \
ricochet_he \
ricochet_sl \
ricochet_zh \
ricochet_et_EE \
ricochet_it_IT \
ricochet_nb \
ricochet_pt_PT \
ricochet_sq \
ricochet_zh_HK \
ricochet_ja
# Only build translations when creating the primary makefile.
!build_pass: {
contains(QMAKE_HOST.os,Windows):QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease.exe
else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
for (translation, TRANSLATIONS) {
system($$QMAKE_LRELEASE translation/$${translation}.ts -qm translation/$${translation}.qm)
}
}
RESOURCES += translation/embedded.qrc
.pri file Protobuf
PROTOC = protoc
unix {
PKG_CONFIG = $$pkgConfigExecutable()
# All our dependency resolution depends on pkg-config. If it isn't
# available, the errors we will get subsequently are a lot more cryptic than
# this.
!system($$PKG_CONFIG --version 2>&1 > /dev/null) {
error("pkg-config executable is not available. please install it so I can find dependencies.")
}
!contains(QT_CONFIG, no-pkg-config) {
CONFIG += link_pkgconfig
PKGCONFIG += protobuf
} else {
# Some SDK builds (e.g. OS X 5.4.1) are no-pkg-config, so try to hack the linker flags in.
QMAKE_LFLAGS += $$system($$PKG_CONFIG --libs protobuf)
}
gcc|clang {
# Add -isystem for protobuf includes to suppress some loud compiler warnings in their headers
PROTOBUF_CFLAGS = $$system($$PKG_CONFIG --cflags protobuf)
PROTOBUF_CFLAGS ~= s/^(?!-I).*//g
PROTOBUF_CFLAGS ~= s/^-I(.*)/-isystem \\1/g
QMAKE_CXXFLAGS += $$PROTOBUF_CFLAGS
}
}
win32 {
isEmpty(PROTOBUFDIR):error(You must pass PROTOBUFDIR=path/to/protobuf to qmake on this platform)
INCLUDEPATH += $${PROTOBUFDIR}/include
LIBS += -L$${PROTOBUFDIR}/lib -llibprotobuf
contains(QMAKE_HOST.os,Windows):PROTOC = $${PROTOBUFDIR}/bin/protoc.exe
}
protobuf_decl.name = protobuf headers
protobuf_decl.input = PROTOS
protobuf_decl.output = ${QMAKE_FILE_IN_PATH}/${QMAKE_FILE_BASE}.pb.h
protobuf_decl.commands = $$PROTOC --cpp_out=${QMAKE_FILE_IN_PATH} --proto_path=${QMAKE_FILE_IN_PATH} ${QMAKE_FILE_NAME}
protobuf_decl.variable_out = HEADERS
QMAKE_EXTRA_COMPILERS += protobuf_decl
protobuf_impl.name = protobuf sources
protobuf_impl.input = PROTOS
protobuf_impl.output = ${QMAKE_FILE_IN_PATH}/${QMAKE_FILE_BASE}.pb.cc
protobuf_impl.depends = ${QMAKE_FILE_IN_PATH}/${QMAKE_FILE_BASE}.pb.h
protobuf_impl.commands = $$escape_expand(\n)
protobuf_impl.variable_out = SOURCES
QMAKE_EXTRA_COMPILERS += protobuf_impl
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
