3

I'm following the arrayfire-rust guide to set up my own Rust project. I can cargo build, but when I cargo run, I get unexpected results. If I run the program directly from the shell, I get the expected results.

$cargo run
Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs
 Running `target/debug/xxx`
 There are 0 available backends

$cargo build
Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs

$./target/debug/xxx
There are 2 available backends

main.rs:

extern crate arrayfire as af;
use af::*;

fn main() {
    println!("There are {:?} available backends", get_backend_count());
}

Cargo.toml

[package]
name = "xxx"
version = "0.1.0"
authors = ["xxx"]

[dependencies]
arrayfire = "3.4.1"

I've filed an issue with the crate, and the maintainers are investigating.

dtolnay
  • 9,621
  • 5
  • 41
  • 62
shusson
  • 5,542
  • 34
  • 38
  • 1
    It'd be nice to get some feedback on the down vote, I'm new to the rust dev environment and any help is appreciated – shusson Jan 11 '17 at 23:46
  • That function [appears to be pretty self-contained](https://github.com/arrayfire/arrayfire-rust/blob/456a3354d4d29a38a0b528e5db59eee1f87e5d71/src/backend.rs#L28-L35) and basically only calls the C function with a bit of error handling. It may not be related to Rust at all... – Shepmaster Jan 12 '17 at 00:05
  • I thought that might be the case but the only difference is how the executable is called, which is related to rust? – shusson Jan 12 '17 at 00:08
  • Not *Rust*, really. Rust is done once the file is compiled. *Cargo*, on the other hand, might be doing something to environment variables (nothing interesting I've seen yet). However, if the C code were to fail, it looks like you should be getting an error message from the library. – Shepmaster Jan 12 '17 at 00:13
  • I see, I'll remove the rust tag – shusson Jan 12 '17 at 00:15
  • This relates to a Rust library or possibly Rust package manager, and understanding of Rust is basically required in solving it, so I believe [rust] tag was appropriate. Re-applied tag. – dtolnay Mar 05 '18 at 08:42
  • Are there any data files or plugin libraries that the library requires to run? Doing a cargo run and calling the executable directly might lead to different working directories. – Sebastian Redl Mar 05 '18 at 08:43
  • 2
    Also, is it just me or is there someone going around downvoting every single Rust question? Seems to me every new Rust question I see first goes into the negative. – Sebastian Redl Mar 05 '18 at 08:45

0 Answers0