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

Support for Windows? #16

Closed
Mereep opened this issue Apr 5, 2020 · 5 comments
Closed

Support for Windows? #16

Mereep opened this issue Apr 5, 2020 · 5 comments

Comments

@Mereep
Copy link

Mereep commented Apr 5, 2020

Hello,

I am trying my very first steps in Rust. Actually Peroxide is my first dependency I tried to include into my project. So, it may be a beginners mistake, but I really cannot make it work.

Here is what I did:

  • Included the dependency like:
[dependencies.peroxide]
version = "0.21"
default-features = false
features = ["dataframe"]
  • Compiled (without problems). Cargo build fails with:

= note: LINK : fatal error LNK1181: cannot open input file 'netcdf.lib'

  • Downloaded+Installed netcdf from

https://www.unidata.ucar.edu/software/netcdf/docs/winbin.html

  • Built again, same problem
  • Added lib folder of netcdf manually to PATH
  • Double checked its availability
> where netcdf.lib
>> C:\Program Files\netCDF 4.7.4\lib\netcdf.lib
  • Cleaned the build (cargo clean)
  • built from scratch
  • Dependencies built again fine, particularly:

Compiling netcdf v0.2.0

  • Linker still fails on
error: linking with `link.exe` failed: exit code: 1181
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.25.28610\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\username\\.rustup\\toolchains\\stable-x86_6
4-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\hdtree_rust.30i0fylwf8h8ulnx.rcgu.o" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target
\\debug\\deps\\hdtree_rust.3le9awyzz0gyzza3.rcgu.o" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\hdtree_rust.3mz25962q1j46fjg.rcgu.o" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\d
eps\\hdtree_rust.4g9p2kmszo5plezg.rcgu.o" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\hdtree_rust.4idues0eeqlb3xz9.rcgu.o" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\hdtre
e_rust.5f0n4k1xtlm3wg9l.rcgu.o" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\hdtree_rust.5ga6ebzlel6xoxwm.rcgu.o" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\hdtree_rust.zvd
o8rmrsj7qkqr.rcgu.o" "/OUT:C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\hdtree_rust.exe" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\hdtree_rust.29ih15nz8vqrgzu1.rcgu.o" "/OP
T:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\l
ib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-wind
ows-msvc\\lib\\rustlib\\etc\\libstd.natvis" "/LIBPATH:C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps" "/LIBPATH:C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_
64-pc-windows-msvc\\lib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libperoxide-24bf80c4ddf588c5.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libcsv-2b6c3aeb6abeb573.
rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libryu-d56761e067164813.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libitoa-d7c651340e327dcf.rlib" "C:\\Users\\Richa
rd\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libcsv_core-102be63259463331.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libbstr-d02df58ca68799e4.rlib" "C:\\Users\\username\\Dropbox\\dev\\
hdtree_rust\\target\\debug\\deps\\libregex_automata-0dd02774b7688856.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libbyteorder-6de9b9e550938e5e.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_
rust\\target\\debug\\deps\\libmemchr-e69b91a3f49b729c.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libserde-490de0045ee1405b.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug
\\deps\\librand_distr-f3f2a9aeaf547929.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libmatrixmultiply-0a35a7d21257890c.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps
\\librawpointer-c36da0366a5028e9.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libpuruspe-b3f6429c5fb8c975.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\liborder_st
at-216e1fa5f5fd6ba9.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libjson-00767a04bcc14eb6.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libnetcdf-ab3a9c03658592ea.
rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libnetcdf_sys-cae9d15dc48a360f.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\liblazy_static-14780178ad1d3bd0.rlib" "C:
\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libindexmap-bdaf8fd585f4cea4.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\librand-f1a6813f03c05795.rlib" "C:\\Users\\username\\
Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\librand_chacha-511b7d3a4fe8a2e2.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libppv_lite86-0a2ecd567e7881db.rlib" "C:\\Users\\username\\Dropbox\\
dev\\hdtree_rust\\target\\debug\\deps\\librand_core-5b1cbcc69748ae95.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_rust\\target\\debug\\deps\\libgetrandom-e0be2fffb9b435da.rlib" "C:\\Users\\username\\Dropbox\\dev\\hdtree_
rust\\target\\debug\\deps\\libcfg_if-46d5a3a2d2fb8986.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-93a5cbf3214e1635.rlib" "C:\\Users\\Rich
ard\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-bc497f38bc14ea36.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustl
ib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-cff6a81a38e24acd.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-2fcb3fe3
0807f5cb.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libbacktrace-916d55fe59b6e45e.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64
-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-7f1beeb3aa6031c7.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libu
nwind-0f8323184fc867ad.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-451043412713beed.rlib" "C:\\Users\\username\\.rustup\\toolchains\\st
able-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-e9eb82ffd1eb284e.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\lib
alloc-8a93a70731c0c815.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-6fc8e09b7aa39aaf.rlib" "C:\\Users\\username\\.rust
up\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-05a61bb76241250f.rlib" "C:\\Users\\username\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-wind
ows-msvc\\lib\\libcompiler_builtins-9e67ceffec35e0af.rlib" "netcdf.lib" "netcdf.lib" "advapi32.lib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "msvcrt.lib"
  = note: LINK : fatal error LNK1181: cannot open input file 'netcdf.lib'
  • Notice the double quoted entries at the end of the command like "netcdf.lib" "netcdf.lib" (which also appear for some reason twice?!)
    • At this point there are too many questions: What is generating the link command?
    • is it supposed to find the paths correctly alone?
    • why some entries are duplicated?
    • am I supposed to install the libs by hand at all?
    • if yes: how am I expected to exactly know which versions those should be?
    • how can I make cargo actually recognize them?
  • Too many questions -> Gave up and came here.

Versions:

cargo --version
cargo 1.42.0 (86334295e 2020-01-31)

rustc --version
rustc 1.42.0 (b8cedc004 2020-03-09)

(Windows 10)

@Axect
Copy link
Owner

Axect commented Apr 6, 2020

Hello, @Mereep
I have not tried to use peroxide in Windows 10 before.
So I will try to test on Windows 10, and will comment about it.

@Axect
Copy link
Owner

Axect commented Apr 6, 2020

@Mereep I tested and succeeded.

This problem is derived from linker path.
I don't know the global and permanent solution but there is a project-level solution.

  • Make build.rs in your project directory and add linker path for netcdf
fn main() {
    println!(r"cargo:rustc-link-search=C:\Program Files\netCDF 4.7.4\lib")
}
  • Modify your Cargo.toml
[package]
name = "net_test"
version = "0.1.0"
authors = ["John Doe"]
edition = "2018"
build = "build.rs"

[dependencies]
peroxide = { version="*", features=["dataframe"] }

Then you can build it and run it!

@Mereep
Copy link
Author

Mereep commented Apr 6, 2020

Hi,

thanks this works :)

Still, I wonder why cargo does not allow to do such a thing in tha toml-File. Is there a reason the process works under Linux but not under Windows?

@Axect
Copy link
Owner

Axect commented Apr 7, 2020

@Mereep
Maybe there is the way using Cargo.toml. But I don't know.

My personal reason that works under linux is convenience and performance.

@magnusuMET
Copy link

This is a bug in the netcdf crate, where we do not add the correct path to the linker search path. I hope this will be a non-problem in the future when netcdf can be built statically (see georust/netcdf#56 for progress on this).

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

3 participants