Closed zachlute closed 5 years ago
I'm getting the following linkage error when compiled with --release
but managed to solve it.
= note: build_script_build-ee6089a96cb0df7d.build_script_build.2obu8exa-cgu.9.rcgu.o : error LNK2019: unresolved external symbol zmq_has referenced in function _ZN18build_script_build4main17h0d9b34f4bad19b01E
The problem is that libzmq adds /GL
if build type is not Debug
. So the solution is to explicitly disable that flag.
let dst = Config::new("libzmq")
.cxxflag("/GL-")
.build();
let pattern =
match env::var("PROFILE").unwrap().as_str() {
"debug" => format!("{}\\libzmq-v*-mt-sgd-*.lib", dst.join("lib").display()),
"release" | "bench" => format!("{}\\libzmq-v*-mt-s-*.lib", dst.join("lib").display()),
unknown => {
// cmake crate defaults to release if profile is unknown
eprintln!("Warning: unknown Rust profile={}; assuming release", unknown);
format!("{}\\libzmq-v*-mt-s-*.lib", dst.join("lib").display())
}
};
I did the following improvements in the build script:
static-libzmq
feature in cargo.appveyor.bat
that uses static-libzmq
feature.PS: I wasn't sure how contribution goes when a PR is implemented by two people, so I opened a PR at https://github.com/zachlute/rust-zmq/pull/1 and when he merge it, my changes will appear here.
Works great for me with @oblique 's changes!
Closing this in favor of #241 with a bunch of improvements on my initial change.
This copies a pattern used by many other -sys crates which use a git submodule and build the appropriate native library.
This could probably be used on other platforms, too, but I don't have them available to test right now, and it's less of a problem on a system where you can install libzmq with a package manager anyway.
This still requires that you have CMake installed so that libzmq can use it to build.