Skip to content
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

Could not compile mysqlclient-sys. #1608

Closed
Sjoerd opened this issue Mar 31, 2018 · 7 comments
Closed

Could not compile mysqlclient-sys. #1608

Sjoerd opened this issue Mar 31, 2018 · 7 comments

Comments

@Sjoerd
Copy link

Sjoerd commented Mar 31, 2018

Hello,
I want to connect to a mysql database, but I'm getting the following error:

   Compiling mysqlclient-sys v0.2.3
error: could not find native static library `mysqlclient`, perhaps an -L flag is missing?

error: Could not compile `mysqlclient-sys`.

To learn more, run the command again with --verbose.

Versions

  • Rust: 1.26.0 nightly
  • Diesel: 1.1.1
  • Database: MySQL 5.7.0
  • Operating System Windows 10

Steps to reproduce

Cargo.toml:

[package]
name = "poll"
version = "0.1.0"
authors = ["Gebruiker"]

[dependencies]
rocket = "0.3.6"
rocket_codegen = "0.3.6"
diesel = { version = "1.1.1", features = ["mysql"] }
dotenv = "0.9.0"

** #1286 does not solve the issue for me **

@sgrif
Copy link
Member

sgrif commented Mar 31, 2018

Please have a look at the readme of that crate (https://github.com/sgrif/mysqlclient-sys). If you are still having issues, please open an issue over there.

@sgrif sgrif closed this as completed Mar 31, 2018
@NotIntMan
Copy link

NotIntMan commented Apr 3, 2019

I got the same problem while installing diesel_cli.

> cargo install diesel_cli
    Updating crates.io index
  Installing diesel_cli v1.4.0
   Compiling proc-macro2 v0.4.27
   ...
   Compiling mysqlclient-sys v0.2.4
   Compiling pq-sys v0.4.6
   Compiling thread_local v0.3.6
   Compiling textwrap v0.10.0
   Compiling rand_isaac v0.1.1
   Compiling rand_xorshift v0.1.1
   Compiling rand_hc v0.1.0
   Compiling syn v0.11.11
   Compiling aho-corasick v0.6.10
   Compiling quote v0.6.11
   Compiling idna v0.1.5
error: could not find native static library `mysqlclient`, perhaps an -L flag is missing?

error: aborting due to previous error

error: Could not compile `mysqlclient-sys`.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `diesel_cli v1.4.0`, intermediate artifacts can be found at `C:\Users\D77CB~1.DEM\AppData\Local\Temp\cargo-install2PGYJy`

Caused by:
  build failed

Does this problem solved by anyone? Please, help.

Versions

Rust: 1.33.0 stable
Diesel CLI: 1.4.0
Operating System: Windows 10 x64

@weiznich
Copy link
Member

weiznich commented Apr 3, 2019

@NotIntMan You are missing libmysqlclient. Probably you need to set an environment variable to point to the right directory, but I'm not sure about that (I'm not using windows 🤷‍♂️ ). See the documentation of mysqlclient-sys for details

@liuspatt
Copy link

For windows install https://downloads.mysql.com/archives/c-c/
set
setx MYSQLCLIENT_LIB_DIR "C:\Program Files\MySQL\MySQL Connector C 6.1\lib\vs14"
run
cargo install diesel_cli --no-default-features --features mysql

@youngtrashbag
Copy link

@liuspatt thank man, it worked 😄

@SaintGuacamole
Copy link

SaintGuacamole commented Jan 7, 2023

For everyone on Windows that has WSL2.
The mysqlclient is still not working for me on the Windows Commandline, but opening an ubuntu command line & running apt-get install libmysqlclient-dev followed by cargo install diesel_cli did the trick for me.

@Luberski
Copy link

Luberski commented Mar 2, 2024

@liuspatt How did you know to use this exact name of env variable "MYSQLCLIENT_LIB_DIR"? I'm asking because doing it in path variable results in error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants