sgrif / mysqlclient-sys

Rust bindings for libmysqlclient
Apache License 2.0
37 stars 31 forks source link

Cargo build on Windows 7 target msvc #5

Closed dkislov closed 5 months ago

dkislov commented 7 years ago

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?

itsnotvalid commented 7 years ago

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.

SingingBush commented 6 years ago

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`
raintears commented 6 years ago

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.

jwwb681232 commented 6 years ago

I have the same problem

dten commented 6 years ago

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 👎

itsnotvalid commented 6 years ago

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

dten commented 6 years ago

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 commented 6 years ago

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

weiznich commented 5 months ago

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