4 releases (breaking)

0.8.0 Mar 12, 2023
0.7.0 Jul 8, 2022
0.6.0 Mar 29, 2021
0.5.0 Mar 27, 2021

#2676 in Database interfaces

Download history 1068/week @ 2024-07-21 989/week @ 2024-07-28 887/week @ 2024-08-04 1461/week @ 2024-08-11 1559/week @ 2024-08-18 2268/week @ 2024-08-25 2150/week @ 2024-09-01 2455/week @ 2024-09-08 2176/week @ 2024-09-15 1274/week @ 2024-09-22 1828/week @ 2024-09-29 1768/week @ 2024-10-06 2624/week @ 2024-10-13 1778/week @ 2024-10-20 1647/week @ 2024-10-27 1736/week @ 2024-11-03

7,853 downloads per month
Used in 6 crates (via libpq)

MIT/Apache

11KB
177 lines

pq-sys

Autogenerated Rust bindings for libpq

Building

This repository contains direct, one-to-one mappings to the C functions provided in libpq-fe.h and postgres_ext.h. This library expects that libpq be installed on the system.

The build script of crate will attempt to find the lib path of libpq using the following methods:

  • First, if the environment variable PQ_LIB_DIR is set, it will use its value
  • If the environment variable isn't set, it tries to use pkg-config to locate it. All the config options, such as PKG_CONFIG_ALLOW_CROSS, PKG_CONFIG_ALL_STATIC etc., of the crate pkg-config apply.
  • For MSVC ABI builds the build script will attempt use the library from a vcpkg installation if there is one available. You may need to set VCPKG_ROOT (or run vcpkg integrate install) and run vcpkg install libpq:x64-windows.
  • If it still can't locate the library, it will invoke the Postgres command pg_config --libdir

The build script instructs Cargo to link the library statically if the environmental variable PQ_LIB_STATIC is set. This can be useful, if targeting for a musl target. If pkg-config is being used, it's configuration options will apply.

FAQ

I'm seeing dyld: Symbol not found __cg_jpeg_resync_to_restart on macOS

This is caused when the output of pg_config --libdir is a directory that also contains libjpeg.dylib which differs from the system libjpeg. This is usually caused by install postgres via homebrew, or using postgresapp.com.

If you've installed via homebrew, you should not see this issue unless you've provided features = ["pkg-config"]. You can work around the issue by exporting PQ_LIB_DIR="$(brew --prefix postgres)/lib".

If you've installed postgresql using postgresapp.com, you will not be able to run your binaries using cargo run or cargo test. You can compile the binary manually via cargo build and then run /target/debug/yourapp. You can also manually create a directory that contains only a symlink to libpq.dylib and nothing else, then export PQ_LIB_DIR to that directory. It is recommended that you do not use postgresapp.com.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0–1.9MB
~38K SLoC