5 months ago
Hey there!
i've got a CC linker error while using cargo build --release on Railway using nixpacks. here's the main output:note: /nix/store/j7p46r8v9gcpbxx89pbqlh61zhd33gzv-binutils-2.43.1/bin/ld: cannot find -lpq: No such file or directory
my project ID is 5bd55246-cbfd-4cb0-af81-a126e9fb5969
3 Replies
5 months ago
The error message you're seeing is from the ld linker. When you see a flag like -l<name>, the linker is trying to find a library file named lib<name>.so or lib<name>.a. In your case, -lpq means the linker is searching for the libpq library.
libpq is the official C client library for PostgreSQL. Rust crates that interface with PostgreSQL (like postgres or sqlx with the postgres feature) often depend on this underlying C library to communicate with the database.
You need to explicitly tell Nixpacks to install the development package for libpq before it tries to build your application.
Inside your nixpacks.toml file, you need to add the necessary PostgreSQL library to the [packages] section. For Nix, the package you need is typically postgresql.lib.
# nixpacks.toml
[phases.setup]
nixPkgs = ["...", "postgresql.lib"]
5 months ago
If the above doesn't work, you can try specifying the library under the [packages] key directly:
[packages]
pkgs = ["...", "postgresql.lib"]