undefined reference to `std::thread::_State::~_State()' while creating RSA_PrivateKey - c++

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

You should create an instance of Botan::RSA_PrivateKey :
Botan::RSA_PrivateKey rsa(*rng.get(),1024);

Related

Using DLLs wrapping Windows PackageManager in MinGW

In an attempt to incorporate a windows platform feature into an otherwise crossplatform application, I've made a one-function VC++ DLL in visual studio that uses Windows.Management.Deployment.PackageManager to get some details on all installed windows store apps.
The function works fine as a standalone application, and I can successfully build the DLL with MSVC that links properly with my MinGW main application (I can happily return primitive data from the dll, etc) - but any attempt to execute a function from the dll containing code relating to PackageManager crashes my application in runtime with the unhelpful code -529697949.
Here's some minimal code blocks that replicate:
main.cpp in the main application:
#include <QCoreApplication>
#include "mylib/WindowsAppsLib.h"
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
auto hi = (Helpers::sayHi());
qDebug() << (hi);
return a.exec();
}
dll header:
#pragma once
#define WINDOWSAPPSLIB_API __declspec(dllexport)
namespace Helpers
{
extern "C" WINDOWSAPPSLIB_API const char* sayHi();
}
dll source:
#include "stdafx.h"
#include <sddl.h>
#include <collection.h>
#include "WindowsAppsLib.h"
#include <windows.h>
#using <Windows.winmd>
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace std;
const char* Helpers::sayHi()
{
auto packageManager = ref new Windows::Management::Deployment::PackageManager();
auto packages = packageManager->FindPackages();
return "Hi!";
}
Without the two lines relating to packagemanger, the program runs fine and prints "Hi!". When included, the program crashes with code -529697949 as soon as sayHi() is called. The two lines in themselves have their dependencies available and don't cause exceptions.
Any clues on how I might proceed to investigate this? Nothing I've been able to get out of this system is getting me closer to identifying the problem. Is this the sensible way to access Windows.Management.Deployment.PackageManager from within a plain C++ MinGW application to begin with?

Cannot resolve Symbol otl_connect (otl_connect class not including)

I have been trying to connect to mysql using OTL_ODBC. I have included the OTL header file (otlv4.h) in my Visual Studio 2010 Project but when I try to use otl_connect, it displays the error "Cannot Resolve Symbol otl_connect", and the otl_connect class appears red in colour:
May I know where I'm doing it wrong?
#define OTL_ODBC
#include "otlv4.h"
int main(int argc, char* argv[])
{
otl_connect db;
}
otl_connect is inside namespace odbc. Try odbc::otl_connect.
I had the same today. The solution was to place #include "otlv4.h" after #define OTL_ODBC_MSSQL_2008.

Error: LINK: fatal error LNK1561: entry point must be defined c++

I am getting the following error when trying to compile my code: error LNK1561: entry point must be defined.
Background: I am trying to run a Win32 CONSOLE application and use the Google Tests framework.
I have my main function setup and I've already checked that my Linker is set to Console (/SUBSYSTEM:CONSOLE) per some other suggestions in many questions I've seen. I'm not sure why it doesn't like my main function, because that is defined as the entry point.
Here is my code:
bob.h
#ifndef BOB_BOB_H
#define BOB_BOB_H
#include <string>
using namespace std;
namespace bob {
string hey(const string&);
}
#endif
bob.cpp
#include "bob.h"
using namespace std;
namespace bob {
string hey(const string& theString)
{
return "Whatever."
}
}
bob_tests.cpp
// bob_tests.cpp : Defines the entry point for the console application
//
#include "bob.h"
#include <gtest/gtest.h>
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
TEST(Bob, stating_something)
{
EXPECT_STREQ("Whatever." bob::hey("Tom-ay-to, tom-aaaah-to."));
}
to elaborate further on Mihaylov's post.
In VS, update the project's properties make sure your project No Entry Point linker property is set to NO.
Project Property Page/Linker/Advanced/No Entry Point = No
Next update the linker subsystem property
Project Property Page/Linker/System/SubSystem = Console(/SUBSYSTEM:CONSOLE)
You have to set the entry point. I saw that you written "Console (/SubSystem:CONSOLE)" so I think you are on Visual Studio so what you need to do is to go to Linker->Advanced->(make sure that "No Entry" is set to "No")->Entry must be set to "main".

Qt5, symbolic link to a folder

A dupe-ish question of this question, which (possibly) has got an outdated answer, as I can't get it to work in Qt5.
I wish to create a symbolic link to a folder for a result similar to QFile::link(). Given that QDir doesn't have an equivalent function, QProcess (or an external library) seems like the way out if I'm up to snuff. How would this be managed in Qt5?
Big thanks in advance.
There are shortcuts and hardlinks on Windows. I think mklink refers to hardlinks.
It works for shortcuts:
#include <QCoreApplication>
#include <QFile>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QFile dir("D:\\source-dir");
bool ok = dir.link("D:\\target-dir.lnk");
if (ok)
{
qDebug() << "yeah!";
return 0;
}
else {
qDebug() << "Did not work :(";
return 1;
}
}
In this case you will find a shortcut in the Explorer but you cannot access the file D:\source-dir\Bitmap.bmp by typing D:\target-dir\Bitmap.bmp
I found out that it cannot be done in Qt, so I ended up using the Win32 API instead. Specifically the CreateSymbolicLink() function.

Simple netbeans C++ project doesn't compile

I installed Netbeans and as C++ compiler I installed cygwin. I made a simple project to test out my installation, this is the code:
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
cout << "test";
return 0;
}
This is the error message that it gives: http://pastebin.com/jRRh7MPi
I hope you guys can help me out.
You need to either explicitly link to C++ standard library, or compile using g++ instead of gcc.