Linking with `cc` failed while running an example


#1

Hello all.

I am trying to use arrayfire library in my project. After installing requisite libraries I am trying to
run an example in that crate. I get cc linking error on my machine Ubuntu xenial 16.04.
I contacted the crate administrator fixed all the issues required for the crate. But I am out of ideas now, so was thinking if there is any thing wrong from rust side or in my machine.

This is what I get

--------------------------------------
 dinesh@Personal (master *) /home/dinesh/rudem $  
|  Personal desktop => cargo run --example helloworld 
   Compiling rudem v0.1.0 (file:///home/dinesh/rudem)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/dinesh/rudem/target/debug/examples/helloworld-cb310b835eb372b8.1y16o1qfye96o7m0.rcgu.o" "/home/dinesh/rudem/target/debug/examples/helloworld-cb310b835eb372b8.37u9wm6hxf6h6j0m.rcgu.o" "/home/dinesh/rudem/target/debug/examples/helloworld-cb310b835eb372b8.3rngp6bm2u2q5z0y.rcgu.o" "/home/dinesh/rudem/target/debug/examples/helloworld-cb310b835eb372b8.49a7n47po4ttqjl7.rcgu.o" "/home/dinesh/rudem/target/debug/examples/helloworld-cb310b835eb372b8.4ezmh1vbs95c5ack.rcgu.o" "/home/dinesh/rudem/target/debug/examples/helloworld-cb310b835eb372b8.4sturziau8dmn3kb.rcgu.o" "-o" "/home/dinesh/rudem/target/debug/examples/helloworld-cb310b835eb372b8" "/home/dinesh/rudem/target/debug/examples/helloworld-cb310b835eb372b8.crate.allocator.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/home/dinesh/rudem/target/debug/deps" "-L" "/usr/local/lib" "-L" "/opt/arrayfire-3/lib" "-L" "/usr/lib" "-L" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/dinesh/rudem/target/debug/deps/libarrayfire-c3c93b65c154e72f.rlib" "/home/dinesh/rudem/target/debug/deps/libnum-1541c251baac357b.rlib" "/home/dinesh/rudem/target/debug/deps/libnum_rational-cf0dbf86474f61eb.rlib" "/home/dinesh/rudem/target/debug/deps/libnum_bigint-d2047e830675f57a.rlib" "/home/dinesh/rudem/target/debug/deps/librand-b48933aba981cfb3.rlib" "/home/dinesh/rudem/target/debug/deps/libnum_complex-d97444a9b43eafb7.rlib" "/home/dinesh/rudem/target/debug/deps/librustc_serialize-a78560b7d3eae2f0.rlib" "/home/dinesh/rudem/target/debug/deps/libnum_iter-7068c5dc528bd227.rlib" "/home/dinesh/rudem/target/debug/deps/libnum_integer-598fbe429c8369d2.rlib" "/home/dinesh/rudem/target/debug/deps/libnum_traits-b145bfe34844a04a.rlib" "/home/dinesh/rudem/target/debug/deps/liblibc-a8592aedfc176217.rlib" "/home/dinesh/rudem/target/debug/deps/liblazy_static-fae2d662a1b7b715.rlib" "-Wl,--start-group" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-912509c5d8c60ccd.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-008c42aad548e7dd.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-f68d8e8245e507c6.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-0fe53371ec419e32.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-9dec1cbd51097ce1.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-6a4fb915dd86d140.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-7ebba6af2d3cc324.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-7a26f8b3cf380464.rlib" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-b0c2d164a9741309.rlib" "-Wl,--end-group" "/home/dinesh/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-66d072e25a9acee3.rlib" "-Wl,-Bdynamic" "-l" "util" "-l" "util" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util"
  = note: /home/dinesh/rudem/target/debug/examples/helloworld-cb310b835eb372b8.4sturziau8dmn3kb.rcgu.o: In function `arrayfire::array::Array::new::he61d2c076e2438fb':
      /home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/arrayfire-3.5.0/src/array.rs:150: undefined reference to `af_create_array'
      /home/dinesh/rudem/target/debug/deps/libarrayfire-c3c93b65c154e72f.rlib(arrayfire-c3c93b65c154e72f.arrayfire1.rcgu.o): In function `_$LT$arrayfire..array..Array$u20$as$u20$core..ops..drop..Drop$GT$::drop::h72b8596df274e411':
      /home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/arrayfire-3.5.0/src/array.rs:457: undefined reference to `af_release_array'
      /home/dinesh/rudem/target/debug/deps/libarrayfire-c3c93b65c154e72f.rlib(arrayfire-c3c93b65c154e72f.arrayfire1.rcgu.o): In function `arrayfire::array::print::h9e555ad0ee8c6b22':
      /home/dinesh/.cargo/registry/src/github.com-1ecc6299db9ec823/arrayfire-3.5.0/src/array.rs:495: undefined reference to `af_print_array_gen'
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      

error: aborting due to previous error

error: Could not compile `rudem`.

To learn more, run the command again with --verbose.

#2

If other libs were compiled while you were troubleshooting/installing libraries you may want to try “cargo clean” before “cargo run” or “cargo build” to recompile from scratch. Also make sure that your cargo dependency version numbers are correct, according to their documentation. Hope that helps.


#3

Thanks, it worked.