1


I'm new to c++ and currently trying to create QT login-register GUI app with hashing passwords. For Bcrypt I'm using this library
So, I copied it, created binaries with CMake GUI and than builded them with VS2019. Then added following code into QT .pro file:

LIBS += -L"S:/work/proga/includes/Bcrypt.cpp/build/Release/" -lbcrypt
INCLUDEPATH += S:/work/proga/includes/Bcrypt.cpp/include

and some basic code in main.cpp (include and usage of lib)
But faced errors like this:

:-1: error: release/main.o:main.cpp:(.text+0x122): undefined reference to `bcrypt::generateHash(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int)'

So. How I should fix it?

upd, my .pro file:


QT       += core gui sql

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++17

SOURCES += \
main.cpp \
loginwindow.cpp \
profileinfo.cpp \
registerwindow.cpp \\

HEADERS += \
User.h \
loginwindow.h \
profileinfo.h \
registerwindow.h \\

FORMS += \
loginwindow.ui \
profileinfo.ui \
registerwindow.ui

LIBS += -L"S:/work/proga/includes/Bcrypt.cpp/build/Release/" -lbcrypt
INCLUDEPATH += S:/work/proga/includes/Bcrypt.cpp/include

main.cpp like

#include <iostream>
#include <bcrypt.h>

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

    std::string password = "top_secret";

    std::string hash = bcrypt::generateHash(password);

    std::cout << "Hash: " << hash << std::endl;

    std::cout << "\"" << password << "\" : " << bcrypt::validatePassword(password,hash) << std::endl;
    std::cout << "\"wrong\" : " << bcrypt::validatePassword("wrong",hash) << std::endl;
}

<3

Tried to use another bcrypt lib (this), but also faced undefined reference errors. Maybe I'm dumb (yes), but can't understand what I should do now..
Tryed to read about this such of error, but didn't find any solution for me (I'm dumb)

10
  • 2
    Does this answer your question? Adding external library into Qt Creator project Commented Apr 30, 2024 at 7:39
  • 2
    Looks like you provided the library path, but forgot to ask the linker to link with your bcrypt. Commented Apr 30, 2024 at 7:40
  • I tried to add -lbcrypt after LIBS += -L"...", but that didn't work Commented Apr 30, 2024 at 7:45
  • Oki, is it also reproducible if you don't use github.com/trusch/libbcrypt/tree/master directly? It has BCrypt::generateHash(password); so this additional C++ wrapper from github.com/hilch/Bcrypt.cpp seems redundant. Commented Apr 30, 2024 at 8:13
  • Yes.\ I tried to use another lib, maybe it will work (no). Commented Apr 30, 2024 at 8:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.