diesel: Failed to compile diesel_cli [v0.6.1]

error: linking withccfailed: exit code: 1

note: /usr/bin/ld: cannot find -lpq
/usr/bin/ld: cannot find -lsqlite3
/usr/bin/ld: cannot find -lsqlite3
/usr/bin/ld: cannot find -lsqlite3
collect2: error: ld returned 1 exit status

Just trying to install it via the recommended cargo install diesel_cli

OS: Ubuntu 15.10 sqlite3 installed.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 19 (6 by maintainers)

Most upvoted comments

I’m having this problem as well. Just leaving out a comment here about this, as this might nudge people to fix this. Sorry tho, I’m not competent enough to contribute by adding pull requests

Edit: By some luck, I successfully installed $ cargo install diesel_cli --no-default-features --features postgres in my Ubuntu 20.04.2 LTS , after running this command sudo apt-get install libpq-dev from this link: https://askubuntu.com/questions/672408/can-not-install-libpq-dev-in-ubuntu-14-04

There might be some poor schmuck like me who’ll benefit in this comment of mine.

if you have “note: /usr/bin/ld: cannot find -lsqlite3” then install libsqlite3-dev: $ sudo apt install libsqlite3-dev This works on Rust 1.53.0, Linux Mint 20.2(based on Ubuntu 20.04 LTS)

The same problem on linux mint and VS Code $ cargo install diesel_cli --no-default-features --features postgres = note: /usr/bin/ld: cannot find -lpq collect2: error: ld returned 1 exit status

But the files exist: $ ls /usr/bin/lp* /usr/bin/lp /usr/bin/lpoptions /usr/bin/lpq /usr/bin/lpr /usr/bin/lprm /usr/bin/lp_solve /usr/bin/lpstat

$ ls /usr/bin/pg_c* /usr/bin/pg_config /usr/bin/pg_conftool /usr/bin/pg_createcluster /usr/bin/pg_ctlcluster

$ apt-cache search libpq libpq-dev - header files for libpq5 (PostgreSQL library) libpq5 - PostgreSQL C client library ...

Upon encountering the similar error on Ubuntu 16.04, I got it fixed by installing libsqlite3-dev, libpq-dev and libmysqlclient-dev. And it worked like charm.

Yes, it does. It would be helpful if it were more clear which dependencies were needed. For instance, the build fails complaining about sqlite3. Not about libsqlite3-dev. Not about pkg-config.

And maybe don’t list all requirements for every distro. But do list the ones we encounter and have solved, so others that are faced with similar issues have a clue of where to start looking.

You could think that the message is clear. You’d be mistaken.

I HAD sqlite3 installed. It already worked.

I did not have libsqlite3-dev, nor did I have pkg-config. I also didn’t have cc or libc. None of those are necessary to run either sqlite3 or program in rust.

And the error message does NOT indicate that diesel needs libsqlite3-dev or pkg-config. It says that ld (the linker) can’t find -lsqlite3. Which is useless.

There’s only a few discussions available on this topic with this error. This is the primary source. If it were so clear, it wouldn’t continue to pop up every couple of months.

It is NOT clear. It is a requirement to install diesel, and neither of sqlite3 nor rust. Thus it needs to be made clear. Preferably in the getting-started guide.

Sure! Here’s the error at the end. I fixed it by adding pkg-config and libsqlite3-dev to my Debian distribution.

note: /usr/bin/ld: cannot find -lsqlite3
collect2: error: ld returned 1 exit status
error: aborting due to previous error error: failed to compile diesel_cli v1.4.0, intermediate artifacts can be found at /tmp/cargo-installKSNB1K
Caused by: Could not compile diesel_cli.

Earlier, the linker also complained about missing cc and libc. Since I had been working with rust and compiling my own applications successfully, I had no reason to believe my distribution was missing anything. I had installed other crates without problem.

I still have the complete output for the last build attempt in my terminal buffer. If needed, I can share it via pastebin or something.

The Docker image that compiles your Diesel app needs to have libpq installed.

Angel Daniel Munoz Gonzalez notifications@github.com schrieb am Sa. 9. Dez. 2017 um 05:09:

hey sorry old issue, but what if I run a postgres image on docker? naturally pg won’t be on my path; what’s the course of action then? just plain install?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/diesel-rs/diesel/issues/286#issuecomment-350422352, or mute the thread https://github.com/notifications/unsubscribe-auth/AABOXwiZNeLqUfoq-O-h9qsMLRTezAwVks5s-gf2gaJpZM4ILoUu .

Do you have PG installed? If so, you need to make sure that pg_config is on the path, or that libpq is in /usr/local/include or some other path that ld can see. If you don’t want PG support, then run cargo install diesel_cli --no-default-features --features sqlite

For SQLite, do you have pkg-config installed? Does sqlite3 show up in pkg-config --list-all?