Diesel: Failed to compile diesel_cli [v0.6.1]

Created on 20 Apr 2016  Â·  17Comments  Â·  Source: diesel-rs/diesel

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.

Most helpful comment

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.

All 17 comments

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?

Closing as there's nothing actionable here. I'm happy to help you get your system set up properly, but this is likely a configuration problem. If there is a bug, it's either in pq-sys or libsqlite3-sys

@sgrif Sorry about the delayed response. Not a problem, Do you hang out in any IRC channels on mozilla or freenode?

I'm sometimes in #rust, but the best way to reach me is in our gitter room. Link is in the README

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?

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
.

This still is an issue. It's a Diesel_cli install issue.

I have a virgin Debian distro with rust and sqlite, and installing diesel_cli still fails on packages no-one specified we'd need.

I do specify --no-default-features and --features sqlite.

Pkg-config? What is that? How am I supposed to know I even need that? CC and libc? How am I supposed to know I need that?

The getting-started guide needs to specify these things. It's extremely frustrating and off-putting.

@aev-mambro2 Could you include the output of your build attempt? It's hard to provide specific help, without knowing what specifically went wrong :)

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.

@aev-mambro2 I think that error message is quite clear. If you want to use sqlite you need to have sqlite installed. For ubuntu the corresponding package is libsqlite3-dev. cc and libc should be required by rust anyway (unless you manually configure a bunch of things.).
If you are not able to install sqlite it is also possible to build a version an the fly while building diesel by passing sqlite-bundled as feature flag to diesel_cli.

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.

The getting started guide does indicate that if you get a linker error you are missing some dependency and that you need to install it.
It is unfortunately not possible to list all dependencies for all operating systems.

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.

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.

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
...

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.

actually for any lib-dev , jsut ran into same issue on new 20.04 LTS ubuntu

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gutsle picture gutsle  Â·  4Comments

killercup picture killercup  Â·  3Comments

qmx picture qmx  Â·  3Comments

Fuckoffee picture Fuckoffee  Â·  3Comments

ivan picture ivan  Â·  4Comments