Page 1 of 3

build Import LIB from LibPQ.DLL

PostPosted: Fri Jun 16, 2023 3:32 pm
by Jimmy
hi,

i want to use PostgreSQL and build a "new" LIB for "latest" Version v14

i have done it for HMG / MinGW using Source of TPQSERVER but how with BCC / MSVC :?:

Re: build Import LIB from LibPQ.DLL

PostPosted: Fri Jun 16, 2023 8:06 pm
by nageswaragunupudi
May not be the latest versions, but these libs and dll might work as well
Code: Select all  Expand view
fwh\lib\hppgsql.lib
fwh\lib\libpq.lib
and
fwh\samples\libpq.dll


Also please see fwh\samples\buildh.bat to see the usage.

Re: build Import LIB from LibPQ.DLL

PostPosted: Fri Jun 16, 2023 10:42 pm
by Jimmy
hi,

thx for Answer.

File c:\fwh64\samples\libpq.dll are Version v9.6.3 and 32 Bit (!) and there is no fwh64\lib\libpq.lib

for HMG i have build a Lib "a" (MinGW) for LibPQ.DLL 64 Bit ... but i don´t remember how ...

---

hm ... CLASS TPQSERVER have some Source

Code: Select all  Expand view
c:\hmg.3.4.4\1\hbpgsql\postgres.c
c:\hmg.3.4.4\1\hbpgsql\rddcopy.c
c:\hmg.3.4.4\1\hbpgsql\postgres.ch
c:\hmg.3.4.4\1\hbpgsql\hbpgsql.h
c:\hmg.3.4.4\1\hbpgsql\libpq-fe.h
c:\hmg.3.4.4\1\hbpgsql\tpostgre.prg


c:\hmg.3.4.4\1\hbpgsql\hbpgsql.hbc
Code: Select all  Expand view
description=PostgreSQL wrapper (SQL)

incpaths=.

headers=postgres.ch

libs=${_HB_DYNPREF}${hb_name}${_HB_DYNSUFF}

{unix}libs=pq
{!unix}libs=libpq
{darwin}libpaths=d:\PG\9.5\lib


c:\hmg.3.4.4\1\hbpgsql\hbpgsql.hbp
Code: Select all  Expand view
-hblib
-inc

-o${hb_name}

-w3 -es2

-depkeyhead=hbpgsql:libpq-fe.h
-depcontrol=hbpgsql:no{HB_BUILD_3RDEXT='no'}
-depcontrol=hbpgsql:${HB_WITH_PGSQL}
-depincpath=hbpgsql:d:\PG\9.5\include
-depimplibs=hbpgsql:d:\PG\9.5\lib\libpq.dll

-iflag={mingw64}-a

${hb_name}.hbx

postgres.c
rddcopy.c
tpostgre.prg


this was my *.BAT
Code: Select all  Expand view
rem this is LIBPQ.LIB from PostgreSQL
hbmk2.exe postgres.c rddcopy.c tpostgre.c -Id:\PG\9.5\include -Lc:\hmg.3.4.4\LIB-64 -llibpq-64

c:\hmg.3.4.4\1\hbpgsql\build.log
hbmk2: Dependency 'hbpgsql' found: d:\PG\9.5\include
hbmk2: Found COFF .lib with the same name, falling back to using it instead of
the .dll.
hbmk2: Created import library: liblibpq.a <= d:\PG\9.5\lib\libpq.dll
hbmk2: Creating static library... libhbpgsql.a

what do i need to change for BCC / MSVC to use with Fivewin 64 Bit :?:

Re: build Import LIB from LibPQ.DLL

PostPosted: Sat Jun 17, 2023 9:15 am
by Antonio Linares
Dear Jimmy,

You can use implib.exe to easily create them for both Borland and MSVC, 32 and 64 bits

Re: build Import LIB from LibPQ.DLL

PostPosted: Mon Jun 19, 2023 9:19 pm
by Jimmy
hi Antonio,

how is the Syntax :?:

x:\>C:\BCC7\bin\implib.exe libpq.dl
Embarcadero Implib Version 3.3.0 Copyright (c) 1991-2014 Embarcadero Technologies, Inc.

Syntax: IMPLIB [options] libname[.lib] [@respfile | srcname] [srcname ...]
Options:
-a Add '_' alias for MS flavor cdecl functions
-aa Force the alias even if the function already starts with '_'
-c Case sensitive symbols
-f Force imports by name (with hints)
-s Don't convert stdcall names from Microsoft mangling
-w No Warnings

! Note : i have LibPQ.DLL (32/64 Bit) and want to build a "Import" LIB to use it with Fivewin

Re: build Import LIB from LibPQ.DLL

PostPosted: Tue Jun 20, 2023 7:30 am
by Antonio Linares
Dear Jimmy,

For msvc:
implib.exe LibPQ.lib LibPQ.DLL

For bcc:
implib.exe -a LibPQ.lib LibPQ.DLL

Please notice that msvc does not provide implib.exe, as it is a Borland tool. For msvc you have to use:
dumpbin.exe /exports LibPQ.dll > LibPQ.def
lib.exe /def:LibPQ.def /OUT:LibPQ.lib

If you are using Harbour's hbmk2.exe please remember that it provides a way to automatically create the import libraries:
-depimplibs=dependency:LibPQ.dll

Not sure how the dependency is defined

Re: build Import LIB from LibPQ.DLL

PostPosted: Tue Jun 20, 2023 8:15 am
by nageswaragunupudi
FWH comes bundled with
Code: Select all  Expand view
fwh\lib\libpq.lib  // 32-bit implib
fwh\lib\hbpgsql.lib // harbour postegre lib
fwh\dll\postgre\libpq.dll  // from Postgre
// this dll is also in
fwh\samples\libpq.dll


In addition you also need all the dlls in
fwh\dll\postgre\*.dll
all these dlls are also available in fwh\samples folder.

fwh\samples\buildh.bat includes the link script for these libs.

In other words,. a new user to FWH can effortlessly build a postgre application, without downloading anything and building any implibs on his own just by
Code: Select all  Expand view
buildh mypostgreapp

if he wants to build a working postre 32-bit application using (x)Harbour and bcc.

Once done, then we can go to 64bits in the next step.
For this you need to download and use all 64-bit dlls, build 64bit implib and also build Harbour's hbpgsql.lib in 64 bits.

Quick start can be made just using what FWH offers and just using buildh.bat in practically no time.

Re: build Import LIB from LibPQ.DLL

PostPosted: Tue Jun 20, 2023 8:17 am
by nageswaragunupudi
If any users are now working with 32-bit dlls and libs we already provided with fwh now. in the next version we will endeavor to upgrade 32-bit versions to the latest and also provide 64-bit libs and dlls.

Re: build Import LIB from LibPQ.DLL

PostPosted: Tue Jun 20, 2023 6:15 pm
by Jimmy
hi,

i already have a HMG App using LibPQ.DLL 64 bit Version
but "Import" LIB was build using MinGW and hbmk2

---

as i remember last 32 Bit Version of PostgreSQL "Server" was v9.x
LibPQ.DLL of Version 10 and later are all 64 Bit

to get LibPQ.DLL as 32 Bit you need to download PgAdmin which are still available as 32 Bit

Re: build Import LIB from LibPQ.DLL

PostPosted: Tue Jun 20, 2023 9:28 pm
by Antonio Linares
> Not sure how the dependency is defined

ok, I found how to define it:

-depkeyhead=test:libmariadb64.dll
-depcontrol=test:yes
-depimplibs=test:libmariadb64.dll
-depincpath=test:.

hbmk2: Dependency 'test' found: .
Creating library libmariadb64.lib and object libmariadb64.exp
hbmk2: Created import library: libmariadb64.lib <= libmariadb64.dll

Re: build Import LIB from LibPQ.DLL

PostPosted: Thu Jun 29, 2023 9:03 am
by Jimmy
hi,

it seems i made a Mistake to use *.HBC while using *,MAK (BCC) or *.HBP (MSVC)

under HMG I was used to work with *.HBC, where I had Libs=
but when i use BCC and *.MAK it "seems" not to work :?

after include in *.MAK
Code: Select all  Expand view
       echo c:\fwh\lib\hbpgsql.lib + >> b32.bc
       echo c:\fwh\lib\libpq.lib + >> b32.bc

32 Bit App using BCC work now :)

---

libpq.lib"seem" me the "Original" by PostgreSQL 32 / 64 Bit so my Question was wrong

i need to build a 64 Bit Version of hbpgsql.lib for Fivewin using these Files:
tpostgre.prg
postgres.c
rddcopy.c

i know to use buildh.bat ti build EXE but how to build 64 Bit LIB for MSVC :?:

Re: build Import LIB from LibPQ.DLL

PostPosted: Thu Jun 29, 2023 9:56 am
by Antonio Linares
Dear Jimmy,

Use hbmk2.exe and -hblib in the hbp file, and the files names

Re: build Import LIB from LibPQ.DLL

PostPosted: Fri Jun 30, 2023 5:55 am
by Jimmy
hi Antonio,
Antonio Linares wrote:Use hbmk2.exe and -hblib in the hbp file, and the files names

YES, that seems to work :D

it compile/link now without Problem, under 64 Bit using MSVC, and i got to 1st Step to show "Catalog"

---

to build hbpgsql.LIB your need LibPQ.LIB from PostgreSQL Server and also some *.h
copy LibPQ.LIB into c:\fwh64\lib\

hbpgsql.hbP
Code: Select all  Expand view
-hblib    
-Ic:\fwh64\include
tpostgre.prg
postgres.c
rddcopy.c
-Lc:\fwh64\lib
-lFiveH64
-lFiveHC64
-lgdiplus
-lole32
-lOleDlg
-lversion
xhb.hbc
hbct.hbc
hbwin.hbc
-ldflag=/NODEFAULTLIB:msvcrt
Tpostgre.rc


hbpgsql.hbc
Code: Select all  Expand view
description=PostgreSQL wrapper (SQL)
incpaths=.
headers=postgres.ch
libs=${_HB_DYNPREF}${hb_name}${_HB_DYNSUFF}
{unix}libs=pq
{!unix}libs=libpq


MakeFWLIB.BAT
Code: Select all  Expand view
call "%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
c:\harbour64\bin\win\msvc64\hbmk2 hbpgsql.hbp -comp=msvc64
REN tpostgre.LIB hbpgsql.LIB  

last line ist to "rename" LIB ... how to chagene "output" Lib Name :?:
copy hbpgsql.LIB into c:\fwh64\lib\

i will make a Sample how to use CLASS TPQServer

Re: build Import LIB from LibPQ.DLL

PostPosted: Fri Jun 30, 2023 12:40 pm
by nageswaragunupudi
We already have programs to use PostGre in our samples which use some extensions created by FWH already
Is there any further need to create new classes except for academic interest?
Right now we can work with PostGre server.

Re: build Import LIB from LibPQ.DLL

PostPosted: Fri Jun 30, 2023 8:32 pm
by Jimmy
hi,

yes ,,, but only using (old v9) 32 Bit LibPQ.DLL Interface

i want to use 64 Bit App so i need 64 Bit LibPQ.DLL / LibPQ.LIB
it would be nice if Fivewin 64 Bit Version include "external" 64 Bit LIBs like in 32 bit Version