在 Mac OS 上安装 libpq-dev?

在 Mac OS 上安装 libpq-dev?

libpq-dev有人知道如何在 Mac OS 10.6 上安装吗?

http://packages.debian.org/sid/libpq-dev

似乎没有适用于它的 macport。我可以从源代码安装它吗?如果可以,该如何安装?

非常感谢!

答案1

(尽管主机名看起来像一个普通的 Linux 机器,但这一切都是在我的 MacBook Pro 上完成的)

首先,安装自制

[ 11:45 [email protected] ~ ]$ /usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/Formula/...
/usr/local/Library/Homebrew/...
==> The following directories will be made group writable:
/usr/local/.
/usr/local/bin
/usr/local/lib
/usr/local/lib/pkgconfig
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man1
==> The following directories will have their group set to admin:
/usr/local/.
/usr/local/bin
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man1

Press enter to continue
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin /usr/local/lib /usr/local/lib/pkgconfig /usr/local/share /usr/local/share/man /usr/local/share/man/man1
Password:
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man1
==> Downloading and Installing Homebrew...
Warning: The following *evil* dylibs exist in /usr/local/lib
They may break builds or worse. You should consider deleting them:
/usr/local/lib/libaa.1.dylib
... snip ...
/usr/local/lib/libz.1.2.5.dylib
==> Installation successful!
Now type: brew help

然后,安装PostgreSQL

[ 11:46 [email protected] ~ ]$ brew install postgresql
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
==> Installing postgresql dependency: readline
==> Downloading http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz
######################################################################## 100.0%
==> Downloading patches
######################################################################## 100.0%
==> Patching
patching file vi_mode.c
patching file callback.c
==> ./configure --prefix=/usr/local/Cellar/readline/6.2.1 --mandir=/usr/local/Cellar/readline/6.2.1/share/man --infodir=/usr/local/Cellar/readline/6.2.1/share/info --enable-multibyte
==> make install
==> Caveats
This formula is keg-only, so it was not symlinked into /usr/local.

OS X provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.

Generally there are no consequences of this for you.
If you build your own software and it requires this formula, you'll need
to add its lib & include paths to your build variables:

    LDFLAGS  -L/usr/local/Cellar/readline/6.2.1/lib
    CPPFLAGS -I/usr/local/Cellar/readline/6.2.1/include
==> Summary
/usr/local/Cellar/readline/6.2.1: 30 files, 1.7M, built in 20 seconds
==> Installing postgresql dependency: ossp-uuid
==> Downloading ftp://ftp.ossp.org/pkg/lib/uuid/uuid-1.6.2.tar.gz

curl: (7) couldn't connect to host
Trying a mirror...
==> Downloading http://www.mirrorservice.org/sites/ftp.ossp.org/pkg/lib/uuid/uuid-1.6.2.tar.gz
######################################################################## 100.0%
==> ./configure --disable-debug --without-perl --without-php --without-pgsql --prefix=/usr/local/Cellar/ossp-uuid/1.6.2
==> make
==> make install
/usr/local/Cellar/ossp-uuid/1.6.2: 12 files, 332K, built in 14 seconds
==> Installing postgresql
==> Downloading http://ftp.postgresql.org/pub/source/v9.1.2/postgresql-9.1.2.tar.bz2
######################################################################## 100.0%
==> ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.1.2 --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-python --with-perl --with-ossp-uuid --datadir
==> make install-world
==> Caveats
# Build Notes

If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
  https://github.com/mxcl/homebrew/issues/issue/2510

To build plpython against a specific Python, set PYTHON prior to brewing:
  PYTHON=/usr/local/bin/python  brew install postgresql
See:
  http://www.postgresql.org/docs/9.1/static/install-procedure.html

# Create/Upgrade a Database

If this is your first install, create a database with:
  initdb /usr/local/var/postgres

To migrate existing data from a previous major version (pre-9.1) of PostgreSQL, see:
  http://www.postgresql.org/docs/9.1/static/upgrading.html

# Start/Stop PostgreSQL

If this is your first install, automatically load on login with:
  mkdir -p ~/Library/LaunchAgents
  cp /usr/local/Cellar/postgresql/9.1.2/org.postgresql.postgres.plist ~/Library/LaunchAgents/
  launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist

If this is an upgrade and you already have the org.postgresql.postgres.plist loaded:
  launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
  cp /usr/local/Cellar/postgresql/9.1.2/org.postgresql.postgres.plist ~/Library/LaunchAgents/
  launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist

Or start manually with:
  pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

And stop with:
  pg_ctl -D /usr/local/var/postgres stop -s -m fast

# Other

Some machines may require provisioning of shared memory:
  http://www.postgresql.org/docs/current/static/kernel-resources.html#SYSVIPC

If you want to install the postgres gem, including ARCHFLAGS is recommended:
    env ARCHFLAGS="-arch x86_64" gem install pg

To install gems without sudo, see the Homebrew wiki.
==> Summary
/usr/local/Cellar/postgresql/9.1.2: 2735 files, 36M, built in 2.1 minutes

所有必要的头文件和库应该现在可以安装了:

[ 11:49 [email protected] ~ ]$ locate libpq
/Developer/SDKs/MacOSX10.7.sdk/usr/include/libpq
/Developer/SDKs/MacOSX10.7.sdk/usr/include/libpq/libpq-fs.h
/Developer/SDKs/MacOSX10.7.sdk/usr/include/libpq-events.h
/Developer/SDKs/MacOSX10.7.sdk/usr/include/libpq-fe.h
/Developer/SDKs/MacOSX10.7.sdk/usr/include/postgresql/internal/libpq
/Developer/SDKs/MacOSX10.7.sdk/usr/include/postgresql/internal/libpq/pqcomm.h
/Developer/SDKs/MacOSX10.7.sdk/usr/include/postgresql/internal/libpq-int.h
/Developer/SDKs/MacOSX10.7.sdk/usr/include/postgresql/server/libpq
/Developer/SDKs/MacOSX10.7.sdk/usr/include/postgresql/server/libpq/auth.h
/Developer/SDKs/MacOSX10.7.sdk/usr/include/postgresql/server/libpq/be-fsstubs.h
/Developer/SDKs/MacOSX10.7.sdk/usr/include/postgresql/server/libpq/crypt.h
/Developer/SDKs/MacOSX10.7.sdk/usr/include/postgresql/server/libpq/hba.h
/Developer/SDKs/MacOSX10.7.sdk/usr/include/postgresql/server/libpq/ip.h
/Developer/SDKs/MacOSX10.7.sdk/usr/include/postgresql/server/libpq/libpq-be.h
/Developer/SDKs/MacOSX10.7.sdk/usr/include/postgresql/server/libpq/libpq-fs.h
/Developer/SDKs/MacOSX10.7.sdk/usr/include/postgresql/server/libpq/libpq.h
/Developer/SDKs/MacOSX10.7.sdk/usr/include/postgresql/server/libpq/md5.h
/Developer/SDKs/MacOSX10.7.sdk/usr/include/postgresql/server/libpq/pqcomm.h
/Developer/SDKs/MacOSX10.7.sdk/usr/include/postgresql/server/libpq/pqformat.h
/Developer/SDKs/MacOSX10.7.sdk/usr/include/postgresql/server/libpq/pqsignal.h
/Developer/SDKs/MacOSX10.7.sdk/usr/lib/libpq.5.3.dylib
/Developer/SDKs/MacOSX10.7.sdk/usr/lib/libpq.5.dylib
/Developer/SDKs/MacOSX10.7.sdk/usr/lib/libpq.a
/Developer/SDKs/MacOSX10.7.sdk/usr/lib/libpq.dylib
/Library/WebServer/Documents/postgresql/html/install-windows-libpq.html
/Library/WebServer/Documents/postgresql/html/libpq-async.html
/Library/WebServer/Documents/postgresql/html/libpq-build.html
/Library/WebServer/Documents/postgresql/html/libpq-cancel.html
/Library/WebServer/Documents/postgresql/html/libpq-connect.html
/Library/WebServer/Documents/postgresql/html/libpq-control.html
/Library/WebServer/Documents/postgresql/html/libpq-copy.html
/Library/WebServer/Documents/postgresql/html/libpq-envars.html
/Library/WebServer/Documents/postgresql/html/libpq-events.html
/Library/WebServer/Documents/postgresql/html/libpq-example.html
/Library/WebServer/Documents/postgresql/html/libpq-exec.html
/Library/WebServer/Documents/postgresql/html/libpq-fastpath.html
/Library/WebServer/Documents/postgresql/html/libpq-ldap.html
/Library/WebServer/Documents/postgresql/html/libpq-misc.html
/Library/WebServer/Documents/postgresql/html/libpq-notice-processing.html
/Library/WebServer/Documents/postgresql/html/libpq-notify.html
/Library/WebServer/Documents/postgresql/html/libpq-pgpass.html
/Library/WebServer/Documents/postgresql/html/libpq-pgservice.html
/Library/WebServer/Documents/postgresql/html/libpq-ssl.html
/Library/WebServer/Documents/postgresql/html/libpq-status.html
/Library/WebServer/Documents/postgresql/html/libpq-threading.html
/Library/WebServer/Documents/postgresql/html/libpq.html
/opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/databases/libpqxx
/opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/databases/libpqxx/Portfile
/opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/databases/libpqxx26
/opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/databases/libpqxx26/Portfile
/usr/include/libpq
/usr/include/libpq/libpq-fs.h
/usr/include/libpq-events.h
/usr/include/libpq-fe.h
/usr/include/postgresql/internal/libpq
/usr/include/postgresql/internal/libpq/pqcomm.h
/usr/include/postgresql/internal/libpq-int.h
/usr/include/postgresql/server/libpq
/usr/include/postgresql/server/libpq/auth.h
/usr/include/postgresql/server/libpq/be-fsstubs.h
/usr/include/postgresql/server/libpq/crypt.h
/usr/include/postgresql/server/libpq/hba.h
/usr/include/postgresql/server/libpq/ip.h
/usr/include/postgresql/server/libpq/libpq-be.h
/usr/include/postgresql/server/libpq/libpq-fs.h
/usr/include/postgresql/server/libpq/libpq.h
/usr/include/postgresql/server/libpq/md5.h
/usr/include/postgresql/server/libpq/pqcomm.h
/usr/include/postgresql/server/libpq/pqformat.h
/usr/include/postgresql/server/libpq/pqsignal.h
/usr/lib/libpq.5.3.dylib
/usr/lib/libpq.5.dylib
/usr/lib/libpq.a
/usr/lib/libpq.dylib

相关内容