我有以下文件和错误描述如下:
1- Connection.cpp

#include "iostream"
#include "stdafx.h"
#include "Connection.h"
#include <libpq-fe.h>
using namespace std;

Connection::Connection()
{

}

PGconn *Connection::getConnection()
{
        const char *connStr = "dbname=Fidelity user=postgres password=home hostaddr=127.0.0.1 port=5432";
    PGconn* conn;
    conn = PQconnectdb(connStr);
   /* if(PQstatus(conn) != CONNECTION_OK)
          {
            cout << "\nConnection Failed.";
            PQfinish(conn);
          }
    else
          {
            cout << "\nConnection Successful\n\n";
          }*/
    return conn;
}

2-主文件:

#include "stdafx.h"
#include "DataCorroborationDLL.h"
#include "iostream"
#include "conio.h"
#include "Connection.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;

HMODULE hModule = ::GetModuleHandle(NULL);

if (hModule != NULL)
{
    // initialize MFC and print and error on failure
    if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0))
    {
        // TODO: change error code to suit your needs
        _tprintf(_T("Fatal Error: MFC initialization failed\n"));
        nRetCode = 1;
    }
    else
    {
        cout << "Hello world";
                    Connection con;
        con.getConnection();
        cout <<getch();
    }
}
else
{
    // TODO: change error code to suit your needs
    _tprintf(_T("Fatal Error: GetModuleHandle failed\n"));
    nRetCode = 1;
}

return nRetCode;
}

我已经安装了postgresql的"include Directory",它包含目录和lib目录 . 它识别postgres命令,但不是全部 . 现在当我编译时,我收到此错误:

Connection.obj:错误LNK2001:未解析的外部符号_PQconnectdb
1> C:\ Users \ Irfan \ Desktop \ IGD \ DataCorroborationDLL \ Release \ Tests.exe:致命错误
LNK1120:1个未解析的外部