Skip site navigation (1) Skip section navigation (2)

RE: libpq static link library dowsn't work (M$ VS6)

From: Magnus Hagander <mha(at)sollentuna(dot)net>
To: "'Finn Kettner'" <fk(at)akf(dot)dk>, pgsql-hackers(at)postgresql(dot)org
Subject: RE: libpq static link library dowsn't work (M$ VS6)
Date: 2000-09-27 07:31:00
Message-ID: 215896B6B5E1CF11BC5600805FFEA82103D97F85@sirius.edu.sollentuna.se (view raw or flat)
Thread:
Lists: pgsql-hackers
> Hello again.
> 
> I'm in the process of making a COM wrapper (enabling VB to connect to
> PostGres) for the libpq library using Visual Studio 6.0 Pro, but have
> a few problems. I can make use of the libpq.dll library from the COM
> wrapper, but I thought that it might be a bit better if the actual
> library routines was included in the COM wrapper, and thus making the
> libpq.dll unnedded.
Sounds great. I've been thinking about doing this myself, but never got
around to it... Linking with the static library is definitly a good idea -
it makes it possible to deploy libpq functionality using ActiveX over a
normal webpage, withuot requiring libpq.dll to be installed on every
machine.


> But if I include all the files that make up the library, then I can't
> get a connection. I even tried to make a small test file which works
> ok when using the dll, but doesn't when I include the actual .c files
> which make up the dll and static link library (.lib). Linking with the
> static link library that comes with the dll file doesn't work either.
WHen you use the static library, you need to initialize the Winsock library
yourself. You need code like:
WSADATA wsaData;
if (WSAStartup(MAKEWORD(1, 1), &wsaData)) {
   cout << "Failed to initialize winsock: " << GetLastError() << endl;
   exit(1);
}

The code that handles this in the DLL is located in
src/interfaces/libpq/libpqdll.c - for reference.


> PS. I have also created a project file for the psql application, if
> this has any interest it might as well be included in the furture
> distributions of postgresql. The dll and static link library is also
> more or less finished, but as I can't link with the static link
> library I don't think that it has much interest untill the problem is
> solved.
I originally chose not to include the project file as it can change format
between version os Visual Studio. If you create it in VS6, it cannot be used
in VS5 IIRC. The Makefile format works in both.
You can create a project file while you work and then export that to a
Makefile once things compile (Project -> Export Makefile).


//Magnus

pgsql-hackers by date

Next:From: devikDate: 2000-09-27 08:12:10
Subject: Re: pgsql is 75 times faster with my new index scan
Previous:From: Hiroshi InoueDate: 2000-09-27 07:23:19
Subject: Re: libpq static link library dowsn't work (M$ VS6)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group