New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed to compile `diesel_cli v0.6.1`./usr/bin/ld: cannot find -lpq, cannot find -lsqlite3 #321

Closed
fuyingfuying opened this Issue May 10, 2016 · 12 comments

Comments

Projects
None yet
6 participants
@fuyingfuying

fuyingfuying commented May 10, 2016

Hi, I'm very love rust and very interesting in your project. Currently I'm building a simulation training system using iron, diesel and other rust crates. But when I try to install diesel_cli followed your "getting start" doc, using "cargo install diesel_cli" in bash. But it failed:
2016-05-10 11-25-39

error: linking with `cc` failed: exit code: 1
note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/fuying/.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/tmp/cargo-install.j1yQaQUZOGv2/release/diesel.0.o" "-o" "/tmp/cargo-install.j1yQaQUZOGv2/release/diesel" "-Wl,--gc-sections" "-pie" "-Wl,-O1" "-nodefaultlibs" "-L" "/tmp/cargo-install.j1yQaQUZOGv2/release" "-L" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps" "-L" "/usr/lib" "-L" "/home/fuying/.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libdotenv-695bff8444756e3d.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libdiesel-8d0a380195f8199e.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libregex-9d62d4e55570bda2.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libthread_local-e8b3e196ecb61c7c.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libchrono-80703cb7572bf802.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libnum-f6961afa9fa1a02b.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libthread_id-bcd46c79a620a618.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libbyteorder-f3f7821512ca2fd0.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libtime-750bfdd52feafcb7.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libaho_corasick-e528bf4fdf3954ff.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libregex_syntax-88bc923660c879aa.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libutf8_ranges-5c6a6dacba3be7ce.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libpq_sys-951a1cd1f21ad686.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/liblibsqlite3_sys-755891849c290f5c.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libnum_iter-50df698bc905252c.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libnum_integer-52fdddf28cd8e924.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libnum_traits-555e3a6260c26680.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libmemchr-c555f740a543880f.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/liblibc-6b483f9a7097e9a4.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libclap-9bc84d3c3d1b047d.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libstrsim-cb9b0c8013c1be6f.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libansi_term-60226d3f8fc96ac9.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libbitflags-e61ad67c3301e77d.rlib" "/tmp/cargo-install.j1yQaQUZOGv2/release/deps/libvec_map-f8aa344cc08e9b03.rlib" "/home/fuying/.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-cb705824.rlib" "/home/fuying/.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-cb705824.rlib" "/home/fuying/.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_unicode-cb705824.rlib" "/home/fuying/.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-cb705824.rlib" "/home/fuying/.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-cb705824.rlib" "/home/fuying/.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-cb705824.rlib" "/home/fuying/.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-cb705824.rlib" "/home/fuying/.multirust/toolchains/nightly/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-cb705824.rlib" "-l" "pq" "-l" "sqlite3" "-l" "sqlite3" "-l" "sqlite3" "-l" "util" "-l" "dl" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "util" "-l" "compiler-rt"
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

error: aborting due to previous error
error: failed to compile `diesel_cli v0.6.1`, intermediate artifacts can be found at `/tmp/cargo-install.j1yQaQUZOGv2`

Caused by:
  Could not compile `diesel_cli`.

I've noticed this issue: #286. But how can make sure pg_config is on the path, or libpq is in /usr/local/include or some other path that ld can see.
I'm using ubuntu 15.10, postgresql and sqlite3 have been installed. libpq and libsqlite3 are in path "/usr/lib/x86_64-linux-gnu".
My "/etc/ld.so.conf"are:

include /etc/ld.so.conf.d/*.conf

My "/etc/ld.so.conf.d/x86_64-linux-gnu.conf" are:

# Multiarch support
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu

So, how can i solve this problem, thank you!

@mcasper

This comment has been minimized.

Collaborator

mcasper commented May 10, 2016

Most of the time pg_config will be installed to /usr/bin/pg_config, which is almost definitely on your $PATH. To try and find it on your machine, you could run sudo updatedb && sudo locate pg_config, which will list the absolute paths of files that match. If it's not anywhere, that means you're missing libpq-dev, and will need to install that.

If you're not looking for sqlite support, you should install diesel_cli with

cargo install diesel_cli --no-default-features --features postgres

which won't compile the sqlite libs. If you do want sqlite support, you'll also need to install sqlite on your machine.

@fuyingfuying

This comment has been minimized.

fuyingfuying commented May 10, 2016

@mcasper pg_config is installed to /usr/bin/pg_config in my machine. And it is on my $PATH. But the error still exists.

fuying@fuying-linux:~$ echo $PATH
/home/fuying/.multirust/toolchains/nightly/cargo/bin:/home/fuying/.multirust/toolchains/nightly/bin:/home/fuying/.cargo/bin:/usr/lib/postgresql/9.4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
@sgrif

This comment has been minimized.

Member

sgrif commented May 10, 2016

Do you also have libpq installed?

@mann-ed

This comment has been minimized.

mann-ed commented May 11, 2016

I had the same issue. I found that my postgresql lib was under /usr/pgsql-9.3/lib/. So i symlink the libpq.so.5 to /usr/lib/libpq.so

sudo ln -s /usr/pgsql-9.3/lib/libpq.so.5 /usr/lib/libpq.so

Then it compiled just fine. I'm on Fedora and have postgresql93-libs installed.

Hope that helps.

@fuyingfuying

This comment has been minimized.

fuyingfuying commented May 11, 2016

@sgrif Yes, I have installed libpq. I used the method of @mann-ed . And it works. Thanks for your help

@fuyingfuying

This comment has been minimized.

fuyingfuying commented May 11, 2016

@mann-ed Use your method, and it works, Thanks for your help

@sgrif

This comment has been minimized.

Member

sgrif commented May 11, 2016

I do want to see if we can improve this scenario, as it's a common stumbling point. Can you tell me what the output of pg_config --libdir is when the symlink isn't there? We may need to ask pg_config for the specific file to link against or something.

@fuyingfuying

This comment has been minimized.

fuyingfuying commented May 15, 2016

@sgrif
On my computer, 'pg_config' is not installed:

fuying@fuying-linux:~$ pg_config --libdir
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
@sgrif

This comment has been minimized.

Member

sgrif commented May 15, 2016

@fuyingfuying In #321 (comment) you said it was... Anyway that looks like the root of the problem here, and the message given is definitely the correct solution. I'll see if I can improve the error message in pq-sys when pg_config isn't installed

@fuyingfuying

This comment has been minimized.

fuyingfuying commented May 15, 2016

@sgrif
ok

@xahon

This comment has been minimized.

xahon commented Jan 13, 2018

I just stucked into the same error. I had already installed libpq5 and libmysqlclient20 on my pc. Solution was sudo apt install libpq-dev libmysqlclient-dev and everything compiled successfully with cargo install diesel_cli without extra parameters

@alejandrotamayo

This comment has been minimized.

alejandrotamayo commented Jun 6, 2018

@mann-ed method worked for me in linux mint.
thank you very much!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment