简体   繁体   English

使用 IBPP 使用 C++ 创建 Firebird 数据库

[英]Creating a Firebird database with C++ using IBPP

I'm currently trying to create a Firebird database using C++.我目前正在尝试使用 C++ 创建 Firebird 数据库。 Firebird is installed on my computer. Firebird 安装在我的电脑上。 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 C:\\用户********** \\应用程序数据\\本地的\\ Temp \\ cc2Zhdj3.o:********** CPP :(文本$ _ZN4IBPP15DatabaseFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_S7_S7 _ [__ ZN4IBPP15DatabaseFactoryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_S7_S7 _] +和0xAA):对 `IBPP::DatabaseFactory(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std:: 的未定义引用分配器 > 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: 错误:ld 返回 1 个退出状态

Does anyone have an idea what I did wrong?有谁知道我做错了什么?

As noted by WhozCraig, you are probably not linking with Firebird shared library.正如 WhozCraig 所指出的,您可能没有与 Firebird 共享库链接。 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.如果使用 GCC,请尝试添加链接选项-libpp ,如果您使用的是 MSVC,只需将 IBPP .cpp 文件添加到您的项目中或创建一个静态库并与之链接。

This is wrong:这是错误的:

#define IBPP_WINDOWS = true

It should be :它应该是:

#define IBPP_WINDOWS

you probably downloaded and unzippped the folder ibpp-2-5-3-1-src .您可能下载并解压了文件夹ibpp-2-5-3-1-src In there you should find the folder core which includes the file all_in_one.cpp .在那里你应该找到包含文件all_in_one.cpp的文件夹 core 。 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.只需通过粘贴#include "C:\\remaining_path\\ibpp-2-5-3-1-src\\core\\all_in_one.cpp"将该文件包含在您的程序中,您必须在其中插入文件所在路径的剩余部分 ( all_in_one.cpp) 位于。 You don't have to include the ibpp header additionally since it is already included through the all_in_one file.您不必另外包含 ibpp 标头,因为它已经包含在 all_in_one 文件中。

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!我猜他们只是嫉妒,所以正如我所说:没关系,你会去的地方!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM