Cannot resolve Symbol otl_connect (otl_connect class not including) - c++

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.

Related

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

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);

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?

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".

Using SDL2_gfx issues using C++

When I use SDL2_gfx with the common.c /common.h files that are included with it, and then use the cpp instead of c extension using VS201X, I get the LNK2019: unresolved external symbol _SDL_main
What that means is if I change the file containing main to test.c, it compiles. When I change it back to text.cpp it fails to compile.
I think that indicates that it only works as C, and not C++.
Below is the code I copied from SDL2_gfxPrimitives.c (Spaces added so they would show up):
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include "common.h"
#include "SDL2_gfxPrimitives.h"
static CommonState *state;
int main(int argc, char* argv[])
{
/* Initialize test framework */
state = CommonCreateState(argv, SDL_INIT_VIDEO);
return 1;
}
I need to use the library in C++ but it seems I don't know enough to figure out how. Any help would be appreciated, I've spent two days attempting to figure this out.
This is a little bit of a gotcha for SDL.
What it does is #define main SDL_main
This renames int main(int argc, char *argv[]) into int SDL_main(int argc, char *argv[]).
In order to use it, SDL wants an unmangled SDL_main to link against, and because you simply renamed the test.c -> test.cpp, you didn't add the code to cause this to happen.
It's described in the documentation:
The application's main() function must be called with C linkage, and should be declared like this:
#ifdef __cplusplus
extern "C"
#endif
int main(int argc, char *argv[])
{
}
so if you put the:
#ifdef __cplusplus
extern "C"
#endif
immediately before the declaration of the main function, it should link correctly.
I figured out a fix. I had to put this code in. Also, the answer above is good. Now I know why it happens too. Google did not find that document.
extern "C"
{
#include "common.h"
}

I am getting error in c++ programm while using log4cxx

I am getting error in c++ program while using log4cxx. The error message is:
error:Please initialize the log4cxx system properly
Please help to resolve,
Thanks in advance.
AFAIR you have to configure the log4cxx system at the beginning of your program, e.g. using a BasicConfigurator as shown in this Short introduction to Apache log4cxx:
#include "log4cxx/logger.h"
#include "log4cxx/basicconfigurator.h"
#include "log4cxx/helpers/exception.h"
using namespace log4cxx;
using namespace log4cxx::helpers;
LoggerPtr logger(Logger::getLogger("MyApp"));
int main(int argc, char **argv)
{
// Set up a simple configuration that logs on the console.
BasicConfigurator::configure();
LOG4CXX_INFO(logger, "Entering application.");
// ...
return 0;
}
HTH
Martin