FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour build Import LIB from LibPQ.DLL
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
build Import LIB from LibPQ.DLL
Posted: Fri Jun 16, 2023 03:32 PM
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 :?:
greeting,

Jimmy
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: build Import LIB from LibPQ.DLL
Posted: Fri Jun 16, 2023 08:06 PM
May not be the latest versions, but these libs and dll might work as well
Code (fw): Select all Collapse
fwh\lib\hppgsql.lib
fwh\lib\libpq.lib
and
fwh\samples\libpq.dll
Also please see fwh\samples\buildh.bat to see the usage.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: build Import LIB from LibPQ.DLL
Posted: Fri Jun 16, 2023 10:42 PM
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 (fw): Select all Collapse
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 (fw): Select all Collapse
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 (fw): Select all Collapse
-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 (fw): Select all Collapse
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 :?:
greeting,

Jimmy
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: build Import LIB from LibPQ.DLL
Posted: Sat Jun 17, 2023 09:15 AM

Dear Jimmy,

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: build Import LIB from LibPQ.DLL
Posted: Mon Jun 19, 2023 09:19 PM
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
greeting,

Jimmy
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: build Import LIB from LibPQ.DLL
Posted: Tue Jun 20, 2023 07:30 AM

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: build Import LIB from LibPQ.DLL
Posted: Tue Jun 20, 2023 08:15 AM
FWH comes bundled with
Code (fw): Select all Collapse
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 (fw): Select all Collapse
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.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: build Import LIB from LibPQ.DLL
Posted: Tue Jun 20, 2023 08:17 AM

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.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: build Import LIB from LibPQ.DLL
Posted: Tue Jun 20, 2023 06:15 PM

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

greeting,

Jimmy
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: build Import LIB from LibPQ.DLL
Posted: Tue Jun 20, 2023 09:28 PM
> 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: build Import LIB from LibPQ.DLL
Posted: Thu Jun 29, 2023 09:03 AM
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 (fw): Select all Collapse
        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 :?:
greeting,

Jimmy
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: build Import LIB from LibPQ.DLL
Posted: Thu Jun 29, 2023 09:56 AM

Dear Jimmy,

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: build Import LIB from LibPQ.DLL
Posted: Fri Jun 30, 2023 05:55 AM
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 (fw): Select all Collapse
-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 (fw): Select all Collapse
description=PostgreSQL wrapper (SQL)
incpaths=.
headers=postgres.ch
libs=${_HB_DYNPREF}${hb_name}${_HB_DYNSUFF}
{unix}libs=pq
{!unix}libs=libpq
MakeFWLIB.BAT
Code (fw): Select all Collapse
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
greeting,

Jimmy
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: build Import LIB from LibPQ.DLL
Posted: Fri Jun 30, 2023 12:40 PM

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.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: build Import LIB from LibPQ.DLL
Posted: Fri Jun 30, 2023 08:32 PM

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

greeting,

Jimmy