Jeroen,
I agree with you and do apologize to everyone on the list.
I follow the following instructions from Rob Lemey that are attached
The build seems to work because I do end up with the lib files.
I have the lib files linked under Project->Settings->Link
I am doing a simple "Hello World" command prompt app with a PQconnectdb and
it the file looks like:
// psqltesting3.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "C:\Program Files\PostgreSQL\8.1\include\libpq-fe.h"
int main(int argc, char* argv[])
{
const char *conninfo;
PGconn *conn;
printf("Hello World!\n");
conninfo = "dbname = template1 port = 5435 user = userid";
/* Make a connection to the database */
conn = PQconnectdb(conninfo);
return 0;
---------------------------------------------------------------
When I build the app I get
Linking...
psqltesting3.obj : error LNK2001: unresolved external symbol _PQconnectdb
Debug/psqltesting3.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
-----------------------------------------------------------------
So I am using the wrong libpqxx lib file and need to rebuild using a newer
version but I am not sure what version I should be using or I don't have the
lib file being called right when I build the app.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jeroen T.
Vermeulen
Sent: Friday, July 21, 2006 10:22 AM
To: DEV
Cc: [email protected]
Subject: Re: [libpqxx-general] Using lib files in MSVC++
On Fri, July 21, 2006 20:26, DEV wrote:
> I have been able to compile the lib files for libpqxx I have the
> libpq-fe.h
> file accessed and when I try to compile my app I get an error that I can't
> link to the external reference. So it seems that the lib file I am trying
> to access is not being included. How do I ensure that it is included and
> is
> there a way to check that I am using the correct libpq-fe.h file?
Rule one: if you want people to help you with an error message, show them
what you're trying and what the error message is!
Jeroen
_______________________________________________
Libpqxx-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/libpqxx-general
This is my experience compiling and linking pqxx on Windows...
libpqxx-2.5.5
PostgreSQL 8.1
Visual Studio .NET 2003
Windows XP Pro Service Pack 2
BUILDING PQXX LIBRARIES:
========================
>From the top level libpqxx-2.5.5 source directory:
Fix some problems in the distributed source code:
+ [PostgreSQL 8.1 delivers one libpq.lib which links to libpq.dll and
others:]
Change "include\pqxx\libcompiler.h" to use libpq.lib (NOT libpqdll.lib):
#pragma comment(lib, "libpq") // changed from "libpqdll"
+ [Debugging flags were specified incorrectly in win32/libpqxx.mak for
debug builds:]
Edit "win32/libpqxx.mak" and specify the correct debug compiler flags:
For "dll debug" use these flags:
CPP_EXTRAS=/MDd /Z7 /Od /GZ /D "_DEBUG" /D "_WINDOWS"
For "static debug" use these flags:
CPP_EXTRAS=/MDd /Z7 /Od /GZ /D "_DEBUG" /D "_LIB"
(One problem with the old compiler flags as distributed in 2.5.5 is that
debugging information was being put in ".pdb" files but the nmake process was
deleting them according to rules in the libpqxx.mak file.)
Perform the "standard" configuration steps for Windows:
+ [Install the VisualC++ configuration headers to build pqxx:]
copy
config\sample-headers\compiler\VisualC++.NET-2003\config-internal-compiler.h
include\pqxx\
copy
config\sample-headers\compiler\VisualC++.NET-2003\config-public-compiler.h
include\pqxx\
copy config\sample-headers\libpq\8.0\config-internal-libpq.h include\pqxx\
* [Setup the variables for the (n)Make file...]
Assuming PostgreSQL is installed at C:\PostgreSQL\8.1, ensure that the
following are set in the file
"libpqxx-2.5.5\win32\common":
PGSQLSRC=c:/PostgreSQL/8.1
LIBPATH=/libpath:"c:/PostgreSQL/8.1/lib/ms/"
Run the make:
nmake /f libpqxx.mak STATIC
---------------------------------------------------------------------------------
COMPILING CLIENT SOFTWARE TO CALL LIBPQXX FUNCTIONS:
====================================================
Assuming you will static link to (libpqxx_static.lib or libpqxx_staticD.lib):
Define the pre-processor symbol: PQXX_LIBEXPORT=
If you define this in the Visual C++ IDE project properties, you MUST include
the equals sign (=), otherwise the IDE will define it as 1.
We must define PQXX_LIBEXPORT to nothing if we want to link to the static pqxx
library because pqxx does this:
/* For now, export DLL symbols if _DLL is defined. This is done
automatically
* by the compiler when linking to the dynamic version of the runtime
library,
* according to "gzh"
*/
// TODO: Define custom macro to govern how libpqxx will be linked to client
#if !defined(PQXX_LIBEXPORT) && defined(_DLL)
#define PQXX_LIBEXPORT __declspec(dllimport)
#endif // PQXX_LIBEXPORT _LIB
The "_DLL" symbol mentioned here tells that we are linking against the DLL
versions of the standard and microsoft Runtime Libraries. I don't think this
"_DLL" symbol should not be used to determine how the app will link to libpqxx.
The appliation developer should be able to choose to link to the standard
runtimes dynamically and choose to link to libpqxx statically.
_______________________________________________
Libpqxx-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/libpqxx-general