Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Undefined references for native library. #2

Closed
fpagliughi opened this issue Sep 26, 2017 · 1 comment
Closed

Undefined references for native library. #2

fpagliughi opened this issue Sep 26, 2017 · 1 comment

Comments

@fpagliughi
Copy link

fpagliughi commented Sep 26, 2017

Hi. I just tried to build this on Linux Ubuntu 16.04, using rustc v 1.20.0 and cargo v0.21.0. It's giving me undefined references to the functions in the native library.

[Note that this same combination of tools seem to work fine under Ubuntu 14.04]

$ git clone https://github.com/fitzgen/bindgen-tutorial-bzip2-sys.git
Cloning into 'bindgen-tutorial-bzip2-sys'...
remote: Counting objects: 28, done.
remote: Total 28 (delta 0), reused 0 (delta 0), pack-reused 28
Unpacking objects: 100% (28/28), done.
Checking connectivity... done.

$ cd bindgen-tutorial-bzip2-sys/

$ cargo build
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling glob v0.2.11
   Compiling peeking_take_while v0.1.2
   Compiling vec_map v0.8.0
   Compiling ansi_term v0.9.0
   Compiling cfg-if v0.1.2
   Compiling term v0.4.6
   Compiling void v1.0.2
   Compiling log v0.3.8
   Compiling bitflags v0.8.2
   Compiling libloading v0.4.2
   Compiling rustc-serialize v0.3.24
   Compiling regex-syntax v0.4.1
   Compiling strsim v0.6.0
   Compiling libc v0.2.31
   Compiling lazy_static v0.2.8
   Compiling unicode-width v0.1.4
   Compiling bitflags v0.9.1
   Compiling unicode-xid v0.0.4
   Compiling utf8-ranges v1.0.0
   Compiling unreachable v1.0.0
   Compiling term_size v0.3.0
   Compiling memchr v1.0.1
   Compiling atty v0.2.2
   Compiling clang-sys v0.19.0
   Compiling thread_local v0.3.4
   Compiling textwrap v0.8.0
   Compiling aho-corasick v0.6.3
   Compiling nom v3.2.0
   Compiling clap v2.26.2
   Compiling regex v0.2.2
   Compiling cexpr v0.2.2
   Compiling syntex_pos v0.58.1
   Compiling syntex_errors v0.58.1
   Compiling syntex_syntax v0.58.1
   Compiling env_logger v0.4.3
   Compiling aster v0.41.0
   Compiling syntex v0.58.1
   Compiling quasi v0.32.0
   Compiling quasi_codegen v0.32.0
   Compiling bindgen v0.26.3
   Compiling bindgen-tutorial-bzip2-sys v0.1.0 (file:///home/fmp/tmp/bindgen-tutorial-bzip2-sys)
    Finished dev [unoptimized + debuginfo] target(s) in 80.50 secs

$ cargo test
   Compiling bindgen-tutorial-bzip2-sys v0.1.0 (file:///home/fmp/tmp/bindgen-tutorial-bzip2-sys)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/fmp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/fmp/tmp/bindgen-tutorial-bzip2-sys/target/debug/deps/bindgen_tutorial_bzip2_sys-845fbd2219e8ea65.0.o" "-o" "/home/fmp/tmp/bindgen-tutorial-bzip2-sys/target/debug/deps/bindgen_tutorial_bzip2_sys-845fbd2219e8ea65" "/home/fmp/tmp/bindgen-tutorial-bzip2-sys/target/debug/deps/bindgen_tutorial_bzip2_sys-845fbd2219e8ea65.crate.allocator.o" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "-L" "/home/fmp/tmp/bindgen-tutorial-bzip2-sys/target/debug/deps" "-L" "/home/fmp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-l" "bz2" "-Wl,-Bstatic" "/home/fmp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtest-30d4d638be038598.rlib" "/home/fmp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgetopts-c58b62d995849f6d.rlib" "/home/fmp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libterm-359c3de19d4def40.rlib" "/home/fmp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-29fb1fb52cf57377.rlib" "/home/fmp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-9cbadc6554202be9.rlib" "/home/fmp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-42efcbbdeb607d44.rlib" "/home/fmp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-618c266cf9124966.rlib" "/home/fmp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-3c10208cdd7e61cb.rlib" "/home/fmp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-16f3b02b9a976b94.rlib" "/home/fmp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-bc70b4efeaeb398c.rlib" "/home/fmp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-a0ad42dc8f5856aa.rlib" "/home/fmp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-32f648f7f7567c6c.rlib" "/home/fmp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-21491ce3d14f1ef2.rlib" "/home/fmp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-b9713bd7f605c0b2.rlib" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util"
  = note: /home/fmp/tmp/bindgen-tutorial-bzip2-sys/target/debug/deps/bindgen_tutorial_bzip2_sys-845fbd2219e8ea65.0.o: In function `bindgen_tutorial_bzip2_sys::tests::round_trip_compression_decompression':
          /home/fmp/tmp/bindgen-tutorial-bzip2-sys/src/lib.rs:21: undefined reference to `BZ2_bzCompressInit'
          /home/fmp/tmp/bindgen-tutorial-bzip2-sys/src/lib.rs:38: undefined reference to `BZ2_bzCompress'
          /home/fmp/tmp/bindgen-tutorial-bzip2-sys/src/lib.rs:49: undefined reference to `BZ2_bzCompressEnd'
          /home/fmp/tmp/bindgen-tutorial-bzip2-sys/src/lib.rs:58: undefined reference to `BZ2_bzDecompressInit'
          /home/fmp/tmp/bindgen-tutorial-bzip2-sys/src/lib.rs:74: undefined reference to `BZ2_bzDecompress'
          /home/fmp/tmp/bindgen-tutorial-bzip2-sys/src/lib.rs:86: undefined reference to `BZ2_bzDecompressEnd'
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

error: Could not compile `bindgen-tutorial-bzip2-sys`.

To learn more, run the command again with --verbose.
@fpagliughi
Copy link
Author

Moved this to:
rust-lang/rust-bindgen#1046

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant