Thread: Windows 7 64 bit, Postgres 9 64 bit, MS C++ Express Linker error

Windows 7 64 bit, Postgres 9 64 bit, MS C++ Express Linker error

From
shy guy
Date:
Hi,

Im having link problems and need help.

I have:
Windows 7 64 bit
installed postgresql-9.0.5-1-windows-x62.exe
installed Visual c++ 2008 Express Edition
set c/c++->additional Include Directories (seems to be ok as it compiles if I remove the PGconn and conn lines from the program and only have the libpq-fe.h header.
        set Linker->General->Additional Library Directories
        set Linker->Input->Additional Dependencies (libpq.lib)

Previous on a different older laptop:
       Windows XP
       Postgress 8.4 and 9.1 installed
       Visual c++ 2008 Express Edition
       Same program and settings and it compiled ok against 8.4 and 9.1
       Also had Eclipse with MinGW and it compiled ok against 8.4 and 9.1

So I dont know what I'm doing wrong ... and Im sure its something stupid buts its driving me crazy.
I saw a similar post by "Roy's Email" but there were no responses. :(
Roy, did you fix your problem?

Thanks,
Kim
==================================================================================
#include "stdafx.h"
#include <iostream>
#include <libpq-fe.h>

int _tmain(int argc, _TCHAR* argv[])
{
PGconn *conn = NULL;

conn = PQconnectdb("user=postgres password=test123 dbname=testdb hostaddr=127.0.0.1 port=5432");

return 0;
}

1>Linking...
1>postgres_connection_test.obj : error LNK2019: unresolved external symbol _PQconnectdb referenced in function _wmain
1>C:\Users\kim\Documents\Visual Studio 2008\Projects\postgres_connection_test\Debug\postgres_connection_test.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\kim\Documents\Visual Studio 2008\Projects\postgres_connection_test\postgres_connection_test\Debug\BuildLog.htm"
1>postgres_connection_test - 2 error(s), 0 warning(s)

Re: Windows 7 64 bit, Postgres 9 64 bit, MS C++ Express Linker error

From
Roy's Email
Date:
>Roy, did you fix your problem?

After a fashion, but I regret that it was so long ago that I don't remember exactly what I did.
 
What I _think_ I did, was get the source and rebuild the libraries; in particular, the 'pq' libraries/dll's.  I then used the "release" version of postgres but compiled my program using the 'pq' dll's I had rebuilt.

I'm sorry I can't be more definite about this, but it's been a while since I got things working and the project has been on hold for for the last few months. If there's some way I can be of more help, let me know, but, as I said, my memory is pretty rusty.
 
This was on Win7/64-bit using Visual C++ 2008 Express.  I used postgres 9.0 (9.0.4) [downloaded the 64-bit "packaged" win64 release and used the sources corresponding to that same version].

Regards,

- Roy

=*=*=
Always do right.
This will gratify some people and astonish the rest. - Mark Twain

The truth is rarely pure, and never simple. - Oscar Wilde
 

 

From: shy_guy_001@hotmail.com
To: pgsql-novice@postgresql.org
Subject: [NOVICE] Windows 7 64 bit, Postgres 9 64 bit, MS C++ Express Linker error
Date: Sat, 12 Nov 2011 02:19:43 +0000

.ExternalClass .ecxhmmessage P {padding:0px;} .ExternalClass body.ecxhmmessage {font-size:10pt;font-family:Tahoma;}
Hi,

Im having link problems and need help.

I have:
Windows 7 64 bit
installed postgresql-9.0.5-1-windows-x62.exe
installed Visual c++ 2008 Express Edition
set c/c++->additional Include Directories (seems to be ok as it compiles if I remove the PGconn and conn lines from the program and only have the libpq-fe.h header.
        set Linker->General->Additional Library Directories
        set Linker->Input->Additional Dependencies (libpq.lib)

Previous on a different older laptop:
       Windows XP
       Postgress 8.4 and 9.1 installed
       Visual c++ 2008 Express Edition
       Same program and settings and it compiled ok against 8.4 and 9.1
       Also had Eclipse with MinGW and it compiled ok against 8.4 and 9.1

So I dont know what I'm doing wrong ... and Im sure its something stupid buts its driving me crazy.
I saw a similar post by "Roy's Email" but there were no responses. :(
Roy, did you fix your problem?

Thanks,
Kim
==================================================================================
#include "stdafx.h"
#include <iostream>
#include <libpq-fe.h>

int _tmain(int argc, _TCHAR* argv[])
{
PGconn *conn = NULL;

conn = PQconnectdb("user=postgres password=test123 dbname=testdb hostaddr=127.0.0.1 port=5432");

return 0;
}

1>Linking...
1>postgres_connection_test.obj : error LNK2019: unresolved external symbol _PQconnectdb referenced in function _wmain
1>C:\Users\kim\Documents\Visual Studio 2008\Projects\postgres_connection_test\Debug\postgres_connection_test.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\kim\Documents\Visual Studio 2008\Projects\postgres_connection_test\postgres_connection_test\Debug\BuildLog.htm"
1>postgres_connection_test - 2 error(s), 0 warning(s)