简体   繁体   中英

Unable to install pg gem in windows

I am getting below error while installing pg gem in windows. Command Used: $ gem install pg -- -- with-pg=S:

****Output:****

Building native extensions with: '-- with-pg=S:'
This could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

    c:/RailsInstaller/Ruby2.1.0/bin/ruby.exe extconf.rb -- with-pg=S:
checking for pg_config... yes
Using config values from S:/bin/pg_config.exe
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=c:/RailsInstaller/Ruby2.1.0/bin/ruby
        --with-pg
        --enable-windows-cross
        --disable-windows-cross
        --with-pg-config
        --without-pg-config
        --with-pg_config
        --without-pg_config
        --with-pg-dir
        --without-pg-dir
        --with-pg-include
        --without-pg-include=${pg-dir}/include
        --with-pg-lib
        --without-pg-lib=${pg-dir}/lib
        --with-pqlib
        --without-pqlib
        --with-libpqlib
        --without-libpqlib
        --with-ms/libpqlib
        --without-ms/libpqlib

extconf failed, exit code 1

Gem files will remain installed in c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1
.0/gems/pg-0.18.4 for inspection.
Results logged to c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/extensions/x86
-mingw32/2.1.0/pg-0.18.4/gem_make.out

Through googling i found we should be installing "apt-get install libpq-dev". Can any one tell me how can i do this on windows machine.

If i try "gem install libpq-dev", i am getting below error.

ERROR: Could not find a valid gem 'libpq-dev' (>= 0) in any repository ERROR: Possible alternatives: libevdev, libpixel

Can any one tell me how can i do this on windows machine.

Windows doesn't treat libraries the same as Linux / Mac ; there is no repository like apt-get or brew (although chocolatey is making ground)... you have to download the libs yourself and reference them directly...

Download the PGSQL binary: http://www.enterprisedb.com/products-services-training/pgbindownload

gem install pg -- --with-pg-dir="C:\Path\To\PostgreSQL\9.5"

Very good resource

试试这个会起作用

sudo apt-get install -y libpq-dev build-essential postgresql-server-dev-all libpgsql-ruby postgresql ruby-dev && gem install pg

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM