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

compiling libxml & xmlsec: undefined reference to symbol 'srand@@GLIBC_2.2.5' #141

Open
JoshuaNitschke opened this issue Mar 9, 2022 · 0 comments
Assignees
Labels

Comments

@JoshuaNitschke
Copy link

JoshuaNitschke commented Mar 9, 2022

First of all, I am not sure this is a bug, but rather more likely I didn't do something right? Any suggestions would be helpful.

What did you try to do?

I am trying to build my app that has dependencies on libxml2 and xmlsec. These libraries are not included, so I built them from source following the suggestions in the documentation. I have included my new docker file in my example repo: https://github.com/JoshuaNitschke/rust-musl-builder_example

What happened?

It fails to finish building with the below error:

rust@74c30da02b56:~/src$ cargo build --release --target x86_64-unknown-linux-musl
   Compiling rust-musl-builder v0.1.0 (/home/rust/src)
WARN rustc_codegen_ssa::back::link Linker does not support -static-pie command line option. Retrying with -static instead.
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crt1.o" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crti.o" "/opt/rust/rustup/toolchains/stable-x8
6_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtbegin.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/rust_musl_builder-0abdab2629dfeaa2.rust_musl_builder.0fa1f4e9-cgu.0.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/rust_musl_builder-0a
bdab2629dfeaa2.rust_musl_builder.0fa1f4e9-cgu.1.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/rust_musl_builder-0abdab2629dfeaa2.rust_musl_builder.0fa1f4e9-cgu.10.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/rust_musl_builder-0abdab2629dfeaa2.rust_musl_builder.0f
a1f4e9-cgu.11.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/rust_musl_builder-0abdab2629dfeaa2.rust_musl_builder.0fa1f4e9-cgu.12.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/rust_musl_builder-0abdab2629dfeaa2.rust_musl_builder.0fa1f4e9-cgu.2.rcgu.o" "/home/rust/s
rc/target/x86_64-unknown-linux-musl/release/deps/rust_musl_builder-0abdab2629dfeaa2.rust_musl_builder.0fa1f4e9-cgu.3.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/rust_musl_builder-0abdab2629dfeaa2.rust_musl_builder.0fa1f4e9-cgu.4.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/
release/deps/rust_musl_builder-0abdab2629dfeaa2.rust_musl_builder.0fa1f4e9-cgu.5.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/rust_musl_builder-0abdab2629dfeaa2.rust_musl_builder.0fa1f4e9-cgu.6.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/rust_musl_builder-0abda
b2629dfeaa2.rust_musl_builder.0fa1f4e9-cgu.7.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/rust_musl_builder-0abdab2629dfeaa2.rust_musl_builder.0fa1f4e9-cgu.8.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/rust_musl_builder-0abdab2629dfeaa2.rust_musl_builder.0fa1f4
e9-cgu.9.rcgu.o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/rust_musl_builder-0abdab2629dfeaa2.21tfntb70993l72k.rcgu.o" "-Wl,--as-needed" "-L" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps" "-L" "/home/rust/src/target/release/deps" "-L" "/usr/local/musl/lib" "-L" "/usr/local/m
usl/lib" "-L" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib" "-Wl,-Bstatic" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/libxmlsec-bd1b363e63662ad8.rlib" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/liblazy_static-c03c33d
691abf67a.rlib" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/liblibxml-e0f9293446cc9aa8.rlib" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/liblibc-70ba889effc8716d.rlib" "-Wl,--start-group" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-
linux-musl/lib/libstd-bd288633937fc261.rlib" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libpanic_unwind-d5ca8f542ed71803.rlib" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libminiz_oxide-3f3a3c0
6ab303b52.rlib" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libadler-34b784c556a5ac17.rlib" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libobject-30156cf7870ed168.rlib" "/opt/rust/rustup/toolcha
ins/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libmemchr-42ddd1c995a4526e.rlib" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libaddr2line-27e425dff83cc7fe.rlib" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/l
ib/rustlib/x86_64-unknown-linux-musl/lib/libgimli-27953ea6f34f06aa.rlib" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd_detect-8140e89a3473e3c6.rlib" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/
lib/librustc_demangle-dc264158c76b38a0.rlib" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libhashbrown-6499d2e635982e2a.rlib" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_std_workspace_al
loc-8221281351bf4b54.rlib" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libunwind-55df4fa4e20c6efc.rlib" "-lunwind" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libcfg_if-9ce06dc879286971.rlib" "/
opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/liblibc-c097b71320db773c.rlib" "-lc" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/liballoc-37d12500bef99331.rlib" "/opt/rust/rustup/toolchains/stable-x86
_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_std_workspace_core-63d6ff8598946320.rlib" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libcore-972b93109ce1fa5e.rlib" "-Wl,--end-group" "/opt/rust/rustup/toolchains/stable-x86_64-un
known-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libcompiler_builtins-71972cde1db06d51.rlib" "-Wl,-Bdynamic" "-lssl" "-lxmlsec1-openssl" "-lxmlsec1" "-lcrypto" "-ldl" "-lxml2" "-lm" "-lxml2" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-nostartfiles" "-L" "/opt/rust/rustup/toolchains/stable-x86_64-unknown
-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib" "-L" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained" "-o" "/home/rust/src/target/x86_64-unknown-linux-musl/release/deps/rust_musl_builder-0abdab2629dfeaa2" "-Wl,--gc-sections" "-static" "
-Wl,-zrelro,-znow" "-Wl,-O1" "-nodefaultlibs" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtend.o" "/opt/rust/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtn.o"
  = note: /usr/bin/ld: /usr/local/musl/lib/libcrypto.a(rand_unix.o): undefined reference to symbol 'shmget@@GLIBC_2.2.5'
          //lib/x86_64-linux-gnu/libc.so.6: error adding symbols: DSO missing from command line
          collect2: error: ld returned 1 exit status

  = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile `rust-musl-builder` due to previous error

What did you hope to happen?

I was hoping I would be able to compile this application to the target x86_64-unknown-linux-musl

Does ./test-image work?

Yes

Additional information

N/A

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

No branches or pull requests

2 participants