I'm trying to build a rust program that involves diesel with postgresql on Fedora 31 and the build fails because the linker can't find libpq. As it's reproducible with gcc, I'm using gcc to keep the question shorter.

gcc -L /lib64 -lpq
/usr/bin/ld: cannot find -lpq
ls /lib64 | grep libpq
ldd /lib64/libpq.so.5
        linux-vdso.so.1 (0x00007ffc06ddd000)
        libssl.so.1.1 => /usr/lib64/libssl.so.1.1 (0x00007f4885ea7000)
        libcrypto.so.1.1 => /usr/lib64/libcrypto.so.1.1 (0x00007f4885bc7000)
        libgssapi_krb5.so.2 => /usr/lib64/libgssapi_krb5.so.2 (0x00007f4885b75000)
        libldap_r-2.4.so.2 => /usr/lib64/libldap_r-2.4.so.2 (0x00007f4885b1d000)
        libpthread.so.0 => /usr/lib64/libpthread.so.0 (0x00007f4885afb000)
        libc.so.6 => /usr/lib64/libc.so.6 (0x00007f4885932000)
        libz.so.1 => /usr/lib64/libz.so.1 (0x00007f4885916000)
        libdl.so.2 => /usr/lib64/libdl.so.2 (0x00007f488590f000)
        libkrb5.so.3 => /usr/lib64/libkrb5.so.3 (0x00007f488581e000)
        libk5crypto.so.3 => /usr/lib64/libk5crypto.so.3 (0x00007f4885805000)
        libcom_err.so.2 => /usr/lib64/libcom_err.so.2 (0x00007f48857fe000)
        libkrb5support.so.0 => /usr/lib64/libkrb5support.so.0 (0x00007f48857ec000)
        libkeyutils.so.1 => /usr/lib64/libkeyutils.so.1 (0x00007f48857e3000)
        libresolv.so.2 => /usr/lib64/libresolv.so.2 (0x00007f48857ca000)
        liblber-2.4.so.2 => /usr/lib64/liblber-2.4.so.2 (0x00007f48857b9000)
        libsasl2.so.3 => /usr/lib64/libsasl2.so.3 (0x00007f4885799000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f4885f8c000)
        libselinux.so.1 => /usr/lib64/libselinux.so.1 (0x00007f488576c000)
        libcrypt.so.2 => /usr/lib64/libcrypt.so.2 (0x00007f488572f000)
        libpcre2-8.so.0 => /usr/lib64/libpcre2-8.so.0 (0x00007f488569d000)

libpthread, for example, which also is in lib64, is found:

gcc -L /lib64 -lpthread
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/9/../../../../lib64/crt1.o: in function `_start':

Am I missing something or should this normally be found right away?

1 Answer 1


-lpq causes the linker to look for libpq.so, with no soname suffix. To provide this on Fedora, you should install libpq-devel:

sudo dnf install libpq-devel

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .