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

problems building on windows with stable and syntex #281

Closed
cmsd2 opened this Issue Apr 18, 2016 · 6 comments

Comments

Projects
None yet
2 participants
@cmsd2

cmsd2 commented Apr 18, 2016

i have both sqlite and postgres 64bit libs and bins on my path after a lot of messing about.
i'm using the 64bit stable gnu toolchain v1.8

i can't seem to compile diesel_demo using with-syntex and no default features.
the build.rs has a build dependency of pq-sys but doesn't add the pg_config's libdir to the link path.
i can get build.rs to build finally producing the build exe by ensuring the postgres lib dir is in the path.
but it's dynamically linked to diesel_codegen dll which is in the deps directory and not in the runtime path.
also the diesel_codegen dll is dynamically linked to the rust std library dll, which also isn't in the runtime path.
i figured that maybe it was because diesel_codegen links to libpq.dll so i tried generating a libpq.a with gendef and dlltool. i can't see any other dll deps like openssl.
i'm able to link statically i think to libpq.a now but cargo is still creating a diesel_codegen with crate-type=dylib and prefer-dynamic

got any tips?

@sgrif

This comment has been minimized.

Member

sgrif commented Apr 18, 2016

Digging into it now.

@sgrif

This comment has been minimized.

Member

sgrif commented Apr 18, 2016

So the reason that it's compiling as a dylib is because it needs to be for nightly. I'm looking into if there's a way for me to conditionally set plugin = true for Cargo.toml or if we need to split this into an entirely separate crate.

Since you're able to build by making sure libpq.dll is on the path, go ahead and keep doing that. If you're only using stable, you can remove the diesel_codegen line from dependencies, as it's only needed in [build-dependencies].

@sgrif

This comment has been minimized.

Member

sgrif commented Apr 18, 2016

I think I've got a fix upstream. Confirming that it doesn't break nightly usage.

@sgrif sgrif closed this in f90217f Apr 18, 2016

@sgrif

This comment has been minimized.

Member

sgrif commented Apr 18, 2016

This has been fixed. Your app should compile fine if you point diesel_codegen at git = "https://github.com/diesel-rs/diesel.git". For use with stable, you will also need to change syntex to 0.31.0 and point dotenv_codegen at git as well.

@sgrif

This comment has been minimized.

Member

sgrif commented Apr 18, 2016

For completeness, these are the changes I made to get a working build without libpq.dll on the path for my machine (which is Windows). pg_config.exe does still need to be on the path.

diff --git a/Cargo.toml b/Cargo.toml
index 6661653..d779718 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,13 +5,13 @@ authors = ["Sean Griffin <sean@seantheprogrammer.com>"]
 build = "build.rs"

 [build-dependencies]
-syntex = { version = "0.26.0", optional = true }
-diesel_codegen = { version = "0.5.0", default-features = false, features = ["postgres"] }
-dotenv_codegen = { version = "0.8.0",  optional = true }
+syntex = { version = "0.31.0", optional = true }
+diesel_codegen = { git = "https://github.com/diesel-rs/diesel.git", default-features = false, features = ["postgres"] }
+dotenv_codegen = { git = "https://github.com/slapresta/rust-dotenv.git",  optional = true }

 [dependencies]
 diesel = "0.5.0"
-diesel_codegen = { version = "0.5.0", default-features = false, features = ["postgres"] }
+diesel_codegen = { git = "https://github.com/diesel-rs/diesel.git", default-features = false, features = ["postgres"] }
 dotenv = "0.8.0"
 dotenv_macros = { version = "0.8.0", optional = true }
@cmsd2

This comment has been minimized.

cmsd2 commented Apr 18, 2016

yep that works perfectly. thanks!

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