0

Compiler complaining undefined reference to std::thread::_State::~_State() when I am trying to create RSA_PrivateKey object in Botan C++.

#include <QCoreApplication>
#include <botan/rsa.h>
#include <botan/auto_rng.h>
#include <iostream>

using std::cout;

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
std::unique_ptr<Botan::RandomNumberGenerator> rng(new Botan::AutoSeeded_RNG);
cout << rng->name();

// this line caused the error
 std::unique_ptr<Botan::RSA_PrivateKey> theKey(new Botan::RSA_PrivateKey(*rng.get(),1024));

return a.exec();
}

Error shows like this: Error when creating RSA_PrivateKey in Botan

I'm really not sure why the compiler is complaining. I need help, thanks in advance.

I added the botan library as a static library using the ".a" file. I did it by right-clicking the project folder > add library > External Library. I tried to compile in debug.

Added botan like this

OS: Windows 7

Compiler:Qt 5.11.2 MinGW 32-bit

CloudWave
  • 913
  • 9
  • 16
  • 1
    Was everything compiled with the same compiler and the same settings? Can you produce this error without QT, just standard library+Botan. – Fire Lancer May 14 '19 at 16:09
  • You mean doing the same thing in other IDE like Code::Blocks? – CloudWave May 14 '19 at 16:13
  • Yes, same compiler and settings – CloudWave May 14 '19 at 16:14
  • I don't think this anything to do with Botan. I think it's to do with std::thread (which I think is being brought in by Qt). What happens if `main` is just `{return QCoreApplication(argc,argv).exec(); }`? – Martin Bonner supports Monica May 14 '19 at 16:15
  • 1
    No, I don't think Fire Lancer means "doing the same thing in other IDE". He means "how was the static library generated"? Was that same compiler and settings? – Martin Bonner supports Monica May 14 '19 at 16:17
  • the main can run when it is just {return QCoreApplication(argc,argv).exec(); }, I built the static library using mingw32-make (MinGW 8.1.0) which is not from Qt. Should I built it again using Qt MinGW 5.11.2 32-bit compiler? – CloudWave May 14 '19 at 17:10

1 Answers1

0

You should create an instance of Botan::RSA_PrivateKey :

Botan::RSA_PrivateKey rsa(*rng.get(),1024);