Не могу подключиться к базе данных PostgreSQL

При компиляции есть всегда ошибка 0xc0150002. Может кто-то может помочь?

#include <string>
#include "libpq-fe.h"


/* Close connection to database */
void CloseConn(PGconn* conn)
{
    PQfinish(conn);
    getchar();
    exit(1);
}
/* Establish connection to database */
PGconn* ConnectDB()
{
    PGconn* conn = NULL;
    conn = PQconnectdb("user=postgres password=test123 dbname=testdb hostaddr=127.0.0.1 port=5432");

    // Check to see that the backend connection was successfully made
    if (PQstatus(conn) != CONNECTION_OK)
    {
        printf("Connection to database failed");
        CloseConn(conn);
    }

    printf("Connection to database - OK\n");

    return conn;
}



int main() {
    return 0;
}

Текст ошибки

'ConnectWithDB.exe' (Win32): Loaded 'D:\ConnectWithDB\x64\Debug\ConnectWithDB.exe'. Symbols loaded.
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\libpq.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\ws2_32.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\Wldap32.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbase.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\shell32.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\msvcp_win.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\win32u.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\gdi32full.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140d.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbased.dll'. 
'ConnectWithDB.exe' (Win32): Loaded 'C:\Windows\System32\libssl-1_1-x64.dll'. 
The thread 0x2a74 has exited with code -1072365566 (0xc0150002).
The thread 0xcc0 has exited with code -1072365566 (0xc0150002).
The program '[5396] ConnectWithDB.exe' has exited with code -1072365566 (0xc0150002).

Ответы (0 шт):