bucardo / dbdpg

Perl Postgres driver DBD::Pg aka dbdpg
48 stars 36 forks source link

Can't install on cygwin #128

Open xpusostomos opened 1 month ago

xpusostomos commented 1 month ago

I get an error installing DBD::Pg on cygwin...

$ export POSTGRES_INCLUDE="c:/Program Files/PostgreSQL/15/include"

chris@P14s-Win ~/GITW/cgi
$ ls "$POSTGRES_INCLUDE"
autosprintf.h        cpl_multiproc.h     ecpgerrno.h     libxml              ogrsf_frmts.h        server
cpl_atomic_ops.h     cpl_odbc.h          ecpglib.h       libxslt             openssl              sql3types.h
cpl_auto_close.h     cpl_port.h          ecpgtype.h      localcharset.h      pg_config.h          sqlca.h
cpl_config.h         cpl_progress.h      evdns.h         lz4.h               pg_config_ext.h      sqlda.h
cpl_config_extras.h  cpl_quad_tree.h     event.h         lz4frame.h          pg_config_manual.h   sqlda-compat.h
cpl_conv.h           cpl_spawn.h         evhttp.h        lz4hc.h             pg_config_os.h       sqlda-native.h
cpl_csv.h            cpl_string.h        evrpc.h         memdataset.h        pgtypes.h            unicode
cpl_error.h          cpl_time.h          evutil.h        ogr_api.h           pgtypes_date.h       uuid.h
cpl_hash_set.h       cpl_virtualmem.h    iconv.h         ogr_core.h          pgtypes_error.h      vrtdataset.h
cpl_http.h           cpl_vsi.h           informix        ogr_feature.h       pgtypes_interval.h   zconf.h
cpl_json.h           cpl_vsi_error.h     internal        ogr_featurestyle.h  pgtypes_numeric.h    zlib.h
cpl_list.h           cpl_vsi_virtual.h   libcharset.h    ogr_geocoding.h     pgtypes_timestamp.h  zstd.h
cpl_minixml.h        cplkeywordparser.h  libintl.h       ogr_geometry.h      postgres_ext.h
cpl_minizip_ioapi.h  DOCBparser.h        libpq           ogr_p.h             pthread.h
cpl_minizip_unzip.h  ecpg_config.h       libpq-events.h  ogr_spatialref.h    rawdataset.h
cpl_minizip_zip.h    ecpg_informix.h     libpq-fe.h      ogr_srs_api.h       sched.h
cpan
install DBD::Pg
........
gcc: warning: Files/PostgreSQL/15/include: linker input file unused because linking not done
gcc: error: Files/PostgreSQL/15/include: linker input file not found: No such file or directory
make: *** [Makefile:358: Pg.o] Error 1
  TURNSTEP/DBD-Pg-3.18.0.tar.gz
  /usr/bin/make -- NOT OK
Failed during this command:
 TURNSTEP/DBD-Pg-3.18.0.tar.gz                : make NO

Since postgres is installed in C:/Program Files, a path with a space in it, and the error says "gcc warning Files/PostgreSQL/15/include"... it looks like a classic case of shell variable not quoted, or something like that. BTW, C:/Program Files is the default install location for Postgres on Windows. I would imagine perhaps the error occurs on UNIX too if you happened to have it installed in a path with a space.

esabol commented 1 month ago

What is $^O on Cygwin?

Try editing Makefile.PL and comment out this line:

https://github.com/bucardo/dbdpg/blob/455943ef13e9760585cdc1da7ab27fa6762b0faf/Makefile.PL#L53

and the matching close brace on line 57.

xpusostomos commented 1 month ago

$^O on cygwin is "cygwin".

I take it that I have to git clone from here to do what you suggest. I seem to get some other issues building that, I'll have to find some time to play with it.

esabol commented 1 month ago

@xpusostomos wrote:

I take it that I have to git clone from here to do what you suggest.

No, you can just edit the Makefile.PL file in the CPAN distribution. It looks like you're using the "cpan" command to install? If so, then at the "cpan" prompt, type "look DBD::Pg" and then it will give you a shell in cpan's DBD::Pg installation directory. Then just edit the Makefile.PL file as I previously suggested and "perl Makefile.PL" and "make" and "make test".

xpusostomos commented 1 month ago

Hmm... make test does this:

#
#     ^"C^:^\Program^ Files^\PostgreSQL^\15^\bin^\pg^_ctl^" -D /c/Users/chris/.cpan/build/DBD-Pg-3.18.0-8/dbdpg_test_database/data -l logfile start
#
#
t/01connect.t .......... skipped: Connection to database failed, cannot continue testing
Can't use an undefined value as a subroutine reference at /usr/share/perl5/5.40/TAP/Harness.pm line 612.
make: *** [Makefile:988: test_dynamic] Error 255

I guess it's trying to create a database to test... I'm not sure why it asks me to run a database server, I have one running all the time... or what its requirements or assumptions are to create a database and connect to it..

... anyway, I did a make install, which seemed to work... and back in cpan I did install DBD::Pg and it said

Reading '/c/Users/chris/.cpan/Metadata'
  Database was generated on Fri, 27 Sep 2024 03:52:39 GMT
DBD::Pg is up to date (3.18.0).

So that sounds good, however... when I try and run a perl pg program...

install_driver(Pg) failed: Can't locate DBD/Pg.pm in @INC (you may need to install the DBD::Pg module) (@INC entries checked: /usr/local/lib/perl5/site_perl/5.40/x86_64-cygwin-threads /usr/local/share/perl5/site_perl/5.40 /usr/lib/perl5/vendor_perl/5.40/x86_64-cygwin-threads /usr/share/perl5/vendor_perl/5.40 /usr/lib/perl5/5.40/x86_64-cygwin-threads /usr/share/perl5/5.40) at (eval 5) line 3.
Perhaps the DBD::Pg perl module hasn't been fully installed,
or perhaps the capitalisation of 'Pg' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Mem, Proxy, Sponge.
 at ./lib/database.pl line 56.

so cpan seems to think it's installed, but perl seems to think it isn't.

esabol commented 1 month ago

Without seeing the output of your "make install", which you haven't provided, it's impossible to diagnose what your problem is.

So do "make install" again and pay closer attention to where it's being installed?