mysqlclient-sys icon indicating copy to clipboard operation
mysqlclient-sys copied to clipboard

Cargo build on Windows 7 target msvc

Open dkislov opened this issue 8 years ago • 8 comments

I cloned repository and tried to build locally: cargo build --verbose. Got error: "error: could not find native static library mysqlclient, perhaps an -L flag is missing?". To solve it I changed in build.rs line 24: println!("cargo:rustc-link-lib=static=libmysql"); <===== libmysql instead of mysqlclient.

Is that bug or somehow could be configured?

dkislov avatar Jun 06 '17 13:06 dkislov

Stuck on this because libmysqlclient/libmysql doesn't build with ming64 as well. I can only use VC ABI and the package names are just different with vcpkg.

Also please consider releasing recent changes relating to vcpkg to cartes.io.

itsnotvalid avatar Jun 16 '17 08:06 itsnotvalid

I guess this is still a problem:

Compiling mysqlclient-sys v0.2.3
     Running `rustc --crate-name mysqlclient_sys C:\Users\singingbush\.cargo\registry\src\github.com-1ecc6299db9ec823\mysqlclient-sys-0.2.3\src\lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=14ffe003dec73a57 -C extra-filename=-14ffe003dec73a57 --out-dir C:\projects\rwp\target\debug\deps -L dependency=C:\projects\rwp\target\debug\deps --cap-lints allow -l static=mysqlclient`

SingingBush avatar Jan 29 '18 19:01 SingingBush

Could you please at least reply how can we resolve this? I tried for weeks with all the suggestions on internet, nothing works with latest mysql

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.

raintears avatar Jul 03 '18 06:07 raintears

I have the same problem

jwwb681232 avatar Aug 21 '18 08:08 jwwb681232

for me i fixed this by moving the vcpkg check first as it was able to correctly find the libraries edit: now i can't reproduce the problem, reality i have no idea i did 👎

dten avatar Sep 04 '18 18:09 dten

@dten can you post your modifications here so we can check? Thanks

itsnotvalid avatar Sep 19 '18 10:09 itsnotvalid

Hey sorry I actually ended up with no changes. Setting the environment variable to static link the CRT sort it for me. Not ideal but it works

dten avatar Sep 19 '18 19:09 dten

actually i tell a lie, i was using my fork and didn't realise it. reverting to the release one resulting in not being able to build. I ended up with:

setting up vckpkg properly (very important)

cargo/.config specifying

[target.x86_64-pc-windows-msvc]
rustflags = ["-Ctarget-feature=+crt-static"]

and using a fork with this change https://github.com/dten/mysqlclient-sys/commit/615b69c97783eb8676d3e620df459af243ab2ed5

dten avatar Oct 04 '18 22:10 dten

I'm closing this as we now have a CI setup that demonstrates that building and linking works on windows.

weiznich avatar May 11 '24 07:05 weiznich