Link error with VC++ linking to libpq.lib

From: Roy's Email <rmw256(at)hotmail(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Link error with VC++ linking to libpq.lib
Date: 2011-07-05 17:38:42
Message-ID: BAY161-w27322F543639DAC5DC9DC7965F0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


Perhaps I asked at the wrong time, so let me try again.

I'm using Visual Studios C++ Express 2008 on Windows 7 with the "standard" (pre-packaged) 64-bit Windows distribution of PostgreSQL v.9.0.4 and I am having unresolved refs when linking to libpq.lib. The relevant elements of my program are:

#include "stdafx.h"
#include "libpq-fe.h"
using namespace System;

int main(array<System::String ^> ^args)
{
...

char *pghost = "localhost",
*pgport = "5432",
*pgoptions = NULL,
*pgtty = NULL;
char *dbName = "mydb";
PGconn *conn;
/* make a connection to the database */
conn = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName);
...
)

Linking against libpq.lib in the postgres "lib" directory, the error I get is:

DBTest.obj : error LNK2001: unresolved external symbol "extern "C" struct pg_conn * __cdecl PQsetdbLogin( ...

So, how do I fix this and get this thing to linik without error?

On a possibly related topic, is it possible to link to static postgres libraries and not require the use of the .dll's?

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

Browse pgsql-novice by date

  From Date Subject
Next Message Boyd, Craig 2011-07-06 01:38:40 Server starts, but I can't connect
Previous Message Vincent Ficet 2011-07-05 11:01:26 Re: Bit Varying vs New Column