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

error: Could not compile `mysqlclient-sys`. #1286

Closed
ziselive opened this Issue Oct 31, 2017 · 5 comments

Comments

Projects
None yet
6 participants
@ziselive

ziselive commented Oct 31, 2017

cargo install diesel_cli, error:

error: could not find native static library mysqlclient, maybe an -L flag is missing?

error: Could not compile mysqlclient-sys.

……………………
mysql version 5.7
win7 x64
rust 1.22.0-nightly

@weiznich

This comment has been minimized.

Contributor

weiznich commented Oct 31, 2017

Try setting MYSQLCLIENT_LIB_DIR to point to the directory where mysqlclient.dll is stored.

@weiznich weiznich added the mysql label Nov 7, 2017

@forbjok

This comment has been minimized.

forbjok commented Dec 3, 2017

I'm having the same issue on Windows 10 x64.
I don't have MySQL in any shape or form installed, and I have no intention of using it.
This seems like it should be an optional component only required if you are actually using MySQL.

UPDATE:
I tried installing the MySQL C connector from mysql.com, pointing MYSQLCLIENT_LIB_DIR to it, and even renaming the libmysql.dll and .lib files to libmysqlclient.* like the package seems to expect, but it did not work.

However, it's possible to disable building the MySQL support by specifing "--no-default-features --features postgres" on the cargo commandline, so if you aren't using MySQL that would solve this particular issue. Now I'm getting a linking error on libpq.lib instead. (presumably unrelated to this issue)

UPDATE 2:
Fixed that last problem by setting the PQ_LIB_DIR environment variable to Postgresql's lib directory.

@sgrif

This comment has been minimized.

Member

sgrif commented Dec 3, 2017

We call this out explicitly in the getting started guide

screen shot 2017-12-03 at 1 24 56 pm

@sgrif sgrif closed this Dec 3, 2017

@eastuto

This comment has been minimized.

eastuto commented Mar 2, 2018

for anyone wanting to actually use MySQL and who is having issues running cargo install, just to clarify adding the location of mysqlclient.lib to your environment variables will fix this.

E.g.

MYSQLCLIENT_LIB_DIR=C:\Program Files\MySQL\MySQL Connector C 6.1\lib\vs14

@sbwtw

This comment has been minimized.

sbwtw commented Sep 27, 2018

Tips:
if you build failed and follow this issue to change your environment variable, you should execute cargo clean before next build.
seems cargo not re-run build script if you continue last build, and it will always get an error.

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