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

rust fails to compile on linux #238

Open
sk337 opened this issue Jun 17, 2024 · 6 comments
Open

rust fails to compile on linux #238

sk337 opened this issue Jun 17, 2024 · 6 comments

Comments

@sk337
Copy link

sk337 commented Jun 17, 2024

error log

   Compiling bitflags v2.5.0
   Compiling libmem-sys v5.0.0
   Compiling libmem v5.0.0
   Compiling libmemTest v0.1.0 (/home/sk337/Projects/rust/libmemTest)
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/sk337/.rbenv/bin:/home/sk337/.juliaup/bin:/home/sk337/.local/share/pnpm:/home/sk337/.bun/bin:/home/sk337/.nvm/versions/node/v22.1.0/bin:/home/sk337/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/sk337/.dotnet/tools:/home/sk337/.local/bin:/home/sk337/Projects/rust/nomad/target/release:/home/sk337/Downloads/patcher" VSLANG="1033" "cc" "-m64" "/tmp/rustcOb7zZq/symbols.o" "/home/sk337/Projects/rust/libmemTest/target/debug/deps/libmemTest-c55c278608eb1877.148rz7rjedmb8yd1.rcgu.o" "/home/sk337/Projects/rust/libmemTest/target/debug/deps/libmemTest-c55c278608eb1877.1vbp0lx0sogim1vy.rcgu.o" "/home/sk337/Projects/rust/libmemTest/target/debug/deps/libmemTest-c55c278608eb1877.235kxcw30nkoqjf0.rcgu.o" "/home/sk337/Projects/rust/libmemTest/target/debug/deps/libmemTest-c55c278608eb1877.23gnqtdu7s9tmuwp.rcgu.o" "/home/sk337/Projects/rust/libmemTest/target/debug/deps/libmemTest-c55c278608eb1877.316kr4lq4vjb3lo0.rcgu.o" "/home/sk337/Projects/rust/libmemTest/target/debug/deps/libmemTest-c55c278608eb1877.4hj08rbuhj4bytla.rcgu.o" "/home/sk337/Projects/rust/libmemTest/target/debug/deps/libmemTest-c55c278608eb1877.4nj4f9gz4nbqgeew.rcgu.o" "/home/sk337/Projects/rust/libmemTest/target/debug/deps/libmemTest-c55c278608eb1877.57h7hjb3wp7jx33m.rcgu.o" "/home/sk337/Projects/rust/libmemTest/target/debug/deps/libmemTest-c55c278608eb1877.31a14n9i9b6v24c0.rcgu.o" "-Wl,--as-needed" "-L" "/home/sk337/Projects/rust/libmemTest/target/debug/deps" "-L" "/home/sk337/Projects/rust/libmemTest/target/debug/build/libmem-sys-c77816756184e45f/out/libmem-5.0.0-x86_64-linux-musl-static/lib" "-L" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/sk337/Projects/rust/libmemTest/target/debug/deps/liblibmem-a6c4afced98663db.rlib" "/home/sk337/Projects/rust/libmemTest/target/debug/deps/libbitflags-db11f0c311d2bf8f.rlib" "/home/sk337/Projects/rust/libmemTest/target/debug/deps/liblibmem_sys-0c3a517fe6bddd39.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-d2ef02247056996e.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-fde67f6c4eccaa42.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-2549d0ec992a5666.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-bb9bfc0931d5cad0.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-7c0b91fdc4adc2c5.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-6ec164769e6c2957.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-95326caaef561554.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-704dba0df3717bb7.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-5f0117cb69112303.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-7a95907f1ed0cea5.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-d4aa666f8242aefc.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-9abec8861e966bc7.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-863ac378b60eeb30.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-fc8aa5b7d220f0a9.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-0cc850f1e941238d.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-f7b445210e88e768.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-f37052492751c579.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-fd15ec7f305d48e7.rlib" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-d700583125da6701.rlib" "-Wl,-Bdynamic" "-ldl" "-lm" "-lstdc++" "-llibmem" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/sk337/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/sk337/Projects/rust/libmemTest/target/debug/deps/libmemTest-c55c278608eb1877" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: /usr/bin/ld: /home/sk337/Projects/rust/libmemTest/target/debug/build/libmem-sys-c77816756184e45f/out/libmem-5.0.0-x86_64-linux-musl-static/lib/liblibmem.a(ks.cpp.o): in function `_GLOBAL__sub_I_ks.cpp':
          ks.cpp:(.text.startup._GLOBAL__sub_I_ks.cpp+0x3): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
          /usr/bin/ld: /home/sk337/Projects/rust/libmemTest/target/debug/build/libmem-sys-c77816756184e45f/out/libmem-5.0.0-x86_64-linux-musl-static/lib/liblibmem.a(X86MCTargetDesc.cpp.o): in function `llvm_ks::FeatureBitset::FeatureBitset(std::initializer_list<unsigned int>)':
          X86MCTargetDesc.cpp:(.text._ZN7llvm_ks13FeatureBitsetC2ESt16initializer_listIjE[_ZN7llvm_ks13FeatureBitsetC5ESt16initializer_listIjE]+0x5c): undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
          /usr/bin/ld: /home/sk337/Projects/rust/libmemTest/target/debug/build/libmem-sys-c77816756184e45f/out/libmem-5.0.0-x86_64-linux-musl-static/lib/liblibmem.a(MipsAsmParser.cpp.o): in function `_GLOBAL__sub_I_MipsAsmParser.cpp':
          MipsAsmParser.cpp:(.text.startup._GLOBAL__sub_I_MipsAsmParser.cpp+0xed): undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
          /usr/bin/ld: /home/sk337/Projects/rust/libmemTest/target/debug/build/libmem-sys-c77816756184e45f/out/libmem-5.0.0-x86_64-linux-musl-static/lib/liblibmem.a(MCFragment.cpp.o): in function `llvm_ks::MCFragment::MCFragment(llvm_ks::MCFragment::FragmentType, bool, unsigned char, llvm_ks::MCSection*)':
          MCFragment.cpp:(.text._ZN7llvm_ks10MCFragmentC2ENS0_12FragmentTypeEbhPNS_9MCSectionE+0x7b): undefined reference to `operator new(unsigned long)'
          collect2: error: ld returned 1 exit status
          
  = note: 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#rustc-link-lib)

error: could not compile `libmemTest` (bin "libmemTest") due to 1 previous error

program

use libmem::*;

fn main() {
    let proc = find_process("java");
    if proc.is_none() {
        println!("Couldn't find process");
        return;
    }
    println!("Found process: {}", proc.unwrap().name);
}
@rdbo
Copy link
Owner

rdbo commented Jun 17, 2024

What Linux? Do you have libstdc++ and libc installed?

@sk337
Copy link
Author

sk337 commented Jun 18, 2024

Yes I do and fedora is what I am using

@black-roland
Copy link

Having the same error on Fedora 39 :(

@rdbo
Copy link
Owner

rdbo commented Aug 12, 2024

Does the issue persist in 5.0.1?

@black-roland
Copy link

@rdbo Yes, unfortunately. Here is my error log:

   Compiling test-project v0.1.0 (/home/user/Source_code/test-project)
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/usr/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/user/bin:/home/user/.local/bin:/home/user/.cargo/bin:/home/user/Android/Sdk/platform-tools:/home/user/Android/Sdk/tools:/usr/share/Modules/bin:/usr/lib64/ccache:/home/user/.local/bin:/home/user/.cargo/bin:/home/user/Android/Sdk/platform-tools:/home/user/Android/Sdk/tools:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin" VSLANG="1033" "cc" "-m64" "/tmp/rustceT33KW/symbols.o" "/home/user/Source_code/test-project/target/debug/deps/pa_hass-d6e3db04bbafa82f.12sls6qsw40n8i1c.rcgu.o" "/home/user/Source_code/test-project/target/debug/deps/pa_hass-d6e3db04bbafa82f.1iapm3hm6gj3fvj3.rcgu.o" "/home/user/Source_code/test-project/target/debug/deps/pa_hass-d6e3db04bbafa82f.31wmmvvkuetpjlqp.rcgu.o" "/home/user/Source_code/test-project/target/debug/deps/pa_hass-d6e3db04bbafa82f.3if1cp3sbt8ldsxp.rcgu.o" "/home/user/Source_code/test-project/target/debug/deps/pa_hass-d6e3db04bbafa82f.3x35a972nfbdr25k.rcgu.o" "/home/user/Source_code/test-project/target/debug/deps/pa_hass-d6e3db04bbafa82f.4rwmwhvey6pdu6ra.rcgu.o" "/home/user/Source_code/test-project/target/debug/deps/pa_hass-d6e3db04bbafa82f.wc6ld6umnori6qw.rcgu.o" "/home/user/Source_code/test-project/target/debug/deps/pa_hass-d6e3db04bbafa82f.3i1j3tbkudek1j23.rcgu.o" "-Wl,--as-needed" "-L" "/home/user/Source_code/test-project/target/debug/deps" "-L" "/home/user/Source_code/test-project/target/debug/build/libmem-sys-28d8fa533d8070f7/out/libmem-5.0.1-x86_64-linux-musl-static/lib" "-L" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/user/Source_code/test-project/target/debug/deps/liblibmem-80be28f22da7ee4b.rlib" "/home/user/Source_code/test-project/target/debug/deps/libbitflags-a09448c8393f0fed.rlib" "/home/user/Source_code/test-project/target/debug/deps/liblibmem_sys-e153636b200286ce.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-204403da28d5972b.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-ddaebda35547a44d.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-477c221bccb9a593.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-3fc79f2446c90135.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-4e93c4d7b0a47c1f.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-2e05022b0af32ebc.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-6dc7e0145919af8f.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-883b8079ff6252af.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-df5b0a140be96485.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-6b42d82bc44ed5b6.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-0e9c079fd0484faa.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-fc531124be6c8193.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-643f1f8cfb933ee8.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-d8e0091cf14fd46c.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-b885c82266435372.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-1130be314bc3df61.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-d7fc549b29637a95.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-c8e690ff38075c09.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-c9053203f6cfbaef.rlib" "-Wl,-Bdynamic" "-ldl" "-lm" "-lstdc++" "-llibmem" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/user/Source_code/test-project/target/debug/deps/pa_hass-d6e3db04bbafa82f" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: /usr/bin/ld: /home/user/Source_code/test-project/target/debug/build/libmem-sys-28d8fa533d8070f7/out/libmem-5.0.1-x86_64-linux-musl-static/lib/liblibmem.a(ks.cpp.o): in function `_GLOBAL__sub_I_ks.cpp':
          ks.cpp:(.text.startup._GLOBAL__sub_I_ks.cpp+0x3): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
          /usr/bin/ld: /home/user/Source_code/test-project/target/debug/build/libmem-sys-28d8fa533d8070f7/out/libmem-5.0.1-x86_64-linux-musl-static/lib/liblibmem.a(X86MCTargetDesc.cpp.o): in function `llvm_ks::FeatureBitset::FeatureBitset(std::initializer_list<unsigned int>)':
          X86MCTargetDesc.cpp:(.text._ZN7llvm_ks13FeatureBitsetC2ESt16initializer_listIjE[_ZN7llvm_ks13FeatureBitsetC5ESt16initializer_listIjE]+0x5c): undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
          /usr/bin/ld: /home/user/Source_code/test-project/target/debug/build/libmem-sys-28d8fa533d8070f7/out/libmem-5.0.1-x86_64-linux-musl-static/lib/liblibmem.a(MipsAsmParser.cpp.o): in function `_GLOBAL__sub_I_MipsAsmParser.cpp':
          MipsAsmParser.cpp:(.text.startup._GLOBAL__sub_I_MipsAsmParser.cpp+0xed): undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)'
          /usr/bin/ld: /home/user/Source_code/test-project/target/debug/build/libmem-sys-28d8fa533d8070f7/out/libmem-5.0.1-x86_64-linux-musl-static/lib/liblibmem.a(MCFragment.cpp.o): in function `llvm_ks::MCFragment::MCFragment(llvm_ks::MCFragment::FragmentType, bool, unsigned char, llvm_ks::MCSection*)':
          MCFragment.cpp:(.text._ZN7llvm_ks10MCFragmentC2ENS0_12FragmentTypeEbhPNS_9MCSectionE+0x7b): undefined reference to `operator new(unsigned long)'
          collect2: error: ld returned 1 exit status
          
  = note: 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#rustc-link-lib)

error: could not compile `test-project` (bin "test-project") due to 1 previous error

In the logs I noticed x86_64-linux-musl-static. I'm really bad at C++/Rust but I wonder if musl is expected here because the compiler is seem using x86_64-unknown-linux-gnu.

@black-roland
Copy link

For anyone having the same issue, you can try the binary release. Just unpack the libmem-5.0.1-x86_64-linux-gnu-shared.tar.gz archive to any directory and set environment variables pointing to it:

export LIBMEM_DIR=/path/to/libmem-5.0.1-x86_64-linux-gnu-shared/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/libmem-5.0.1-x86_64-linux-gnu-shared/lib

Also, it's advisable to remove the target dir.

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