Search code examples
rustrust-cargorust-diesel

Rust Diesel failing to compile with linker error


I was using Diesel and it was working with the following Cargo.toml config:

diesel = { version = "1.4.4", features = ["postgres"] }

Running without Diesel and everything is fine. When I introduce the above dependency it fails to compile with the following error:

clang: error: linker command failed with exit code 1 (use -v to see invocation)

OS: MacOS Big Sur

Update I've installed libpq with the following command:

brew install libpq

I then tried to link it with the following command:

brew link --force libpq

This worked. Thanks for the comments that pointed me into this direction.


Solution

  • You need to have postgres installed correctly on your system:

    // ubuntu
    $ sudo apt install libpq-dev
    
    // osx
    $ brew install libpq