通过C ++访问PostgreSQL - 接口(链接器错误) [英] Access PostgreSQL via C++-Interface (Linker error)

查看:201
本文介绍了通过C ++访问PostgreSQL - 接口(链接器错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Im使用visual studio 2012 Ultimate和PostgreSQL 9.2 64位。
我使用以下设置设置了一个全新的项目:

Im using visual studio 2012 Ultimate and PostgreSQL 9.2 64 bit. I set up a completely new project with the following settings:

其他包含文件夹:C:\Program Files\PostgreSQL \ 9.2 \include\

其他libs文件夹:C:\Program Files\PostgreSQL\9.2\lib\\ \\

Additional libs folder: "C:\Program Files\PostgreSQL\9.2\lib\"

Im与 libpq.lib 链接。

我的问题如下:

#include <iostream>
using namespace std;

#include <libpq-fe.h>

int main() {

    PGconn *psql = PQconnectdb("hostaddr = '127.0.0.1' port = '' dbname = 'fwaggle' user = 'fwaggle' password = 'password' connect_timeout = '10'");
    /* init connection */
    if (!psql) {

    }

    std::cin.get();
    return 0;
}

结果:错误LNK2019:Verweis auf nichtaufgelöstesexternes符号_PQconnectdb Funktion_main。我无法摆脱这个链接器错误,我做错了什么?

Result: "error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "_PQconnectdb" in Funktion "_main". I cant get rid of this linker error, what am I doing wrong?

推荐答案

正在进行:

如我所写的安装PostgreSQL 64位,但我试图编译和链接一个32位项目对64位libpg从PostgreSQL
从WIN32更改为x64后,链接成功。

As written I installed PostgreSQL 64 bit but i tried to compile and link a 32 bit project against the 64-bit libpg from PostgreSQL. After changing from WIN32 to x64 linking was successfull.

这篇关于通过C ++访问PostgreSQL - 接口(链接器错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆