1
votes

I'm currently trying to create a Firebird database using C++. Firebird is installed on my computer. My program looks as follows:

#define IBPP_WINDOWS = true
#define IBPP_GCC = true

#include "ibpp.h"
#include <fstream>
#include <iostream>
#include <sstream>
#include <vector>
#include <iostream>
#include <stdlib.h>
#include <sstream>
#include <cmath>

using namespace std;
using std::vector;
using std::string;
using std::ifstream;
using std::ofstream;
using std::getline;
using std::cin;
using std::cout;
using std::endl;
using std::istringstream;

int main(int argc, char *argv[])
{   
    std::string UserName = "SYSDBA";
    std::string Password = "**********";
    std::string ServerName = "localhost";
    char* DbName = (char *)"C:/Users/**********/Desktop/**********.fdb";

    IBPP::Database db =   IBPP::DatabaseFactory(ServerName,DbName,UserName,Password);

    db->Create();
    db->Connect();

}

When I try to compile my code, I get the following message:

C:\Users**********\AppData\Local\Temp\cc2Zhdj3.o:**********.cpp:(.text$_ZN4IBPP15DatabaseFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_S7_S7_[__ZN4IBPP15DatabaseFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_S7_S7_]+0xaa): undefined reference to `IBPP::DatabaseFactory(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&)' collect2.exe: error: ld returned 1 exit status

Does anyone have an idea what I did wrong?

3

3 Answers

2
votes

As noted by WhozCraig, you are probably not linking with Firebird shared library. If using GCC try adding link option -libpp, in case you are using MSVC, just simply add IBPP .cpp files into your project or create a static library and link with that.

1
votes

This is wrong:

#define IBPP_WINDOWS = true

It should be :

#define IBPP_WINDOWS
0
votes

you probably downloaded and unzippped the folder ibpp-2-5-3-1-src. In there you should find the folder core which includes the file all_in_one.cpp. Simply include this file in your program by pasting #include "C:\remaining_path\ibpp-2-5-3-1-src\core\all_in_one.cpp" where you have to insert the remaining part of the path where the file (all_in_one.cpp) is located. You don't have to include the ibpp header additionally since it is already included through the all_in_one file.

This will do the trick :)

And by the way: Never mind that bunch of prats teasing you here. They seem to be complete slaves just doing exactly what authority tells them to, never having learned to think for themselves. I guess they're merely jealous, so as I said: never mind, you'll go places!