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

Compilation error on 'unknown-linux' #181

Closed
Dentrax opened this issue May 6, 2019 · 9 comments
Closed

Compilation error on 'unknown-linux' #181

Dentrax opened this issue May 6, 2019 · 9 comments

Comments

@Dentrax
Copy link

Dentrax commented May 6, 2019

I am trying to build the project on Travis. But unknown-linux distributions won't compiling.

Error:

error: failed to run custom build command for `libdbus-sys v0.1.5`
process didn't exit successfully: `/home/travis/build/Dentrax/Netlyser/target/debug/build/libdbus-sys-6b2f4649fdb71c20/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: 
Failure { 
command: "\"pkg-config\" \"--libs\" \"--cflags\" \"dbus-1 >= 1.6\"", 
output: Output { status: ExitStatus(ExitStatus(256)), stdout: "", 
stderr: "Package dbus-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `dbus-1.pc\'\nto the PKG_CONFIG_PATH environment variable
No package \'dbus-1\' found\n" } }', src/libcore/result.rs:997:5

How can i fix this problem on Travis? @diwic

Thank you!

@diwic
Copy link
Owner

diwic commented May 7, 2019

I'm not familiar with travis but make sure you have development headers for dbus installed. In Debian/Ubuntu based distributions, this means installing the package libdbus-1-dev.

@diwic
Copy link
Owner

diwic commented May 7, 2019

Here are instructions on how to install dependencies: https://docs.travis-ci.com/user/installing-dependencies

It seems like Travis is running some Ubuntu version rather than "unknown-linux"?

@Dentrax
Copy link
Author

Dentrax commented May 7, 2019

@diwic

Hey, thank you. It compiles successfully on x86_64-unknown-linux-gnu

But it is not compiling for i686-unknown-linux-musl Although libdbus-1-dev is installed.

before_install:
  - if [ $TRAVIS_OS_NAME = linux ]; then sudo apt-get install -y libdbus-1-dev

Output:

error: failed to run custom build command for `libdbus-sys v0.1.5`
process didn't exit successfully: `/home/travis/build/Dentrax/Netlyser/target/debug/build/libdbus-sys-6b2f4649fdb71c20/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: CrossCompilation', src/libcore/result.rs:997:5

OS:

Operating System Details
Distributor ID:	Ubuntu
Description:	Ubuntu 14.04.5 LTS
Release:	14.04
Codename:	trusty

@diwic
Copy link
Owner

diwic commented May 8, 2019

I have not done cross compilation myself but according to this comment: #134 (comment)

...a workaround is possibly to set PKG_CONFIG_ALLOW_CROSS=1.

@Dentrax
Copy link
Author

Dentrax commented May 8, 2019

@levex

Ty, After After dozens of tries, i am getting this error:

Env:

- os: linux
      rust: stable
      env: 
      - TARGET=i686-unknown-linux-musl
      - PKG_CONFIG_ALLOW_CROSS=1
      - CC_x86_64_unknown_linux_musl=x86_64-linux-musl-gcc

before_install:

- if [ $TRAVIS_OS_NAME = "linux" ]; then sudo apt-get install -y libdbus-1-dev libdbus-glib-1-dev musl-tools; fi

error: linking with `cc` failed: exit code: 1
  |
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-Wl,--eh-frame-hdr" "-m32" "-Wl,-melf_i386" "-nostdlib" " ........................................"
= note: /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libdbus-1.so when searching for -ldbus-1
          /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libdbus-1.a when searching for -ldbus-1
          /usr/bin/ld: cannot find -ldbus-1
          /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libsqlite3.so when searching for -lsqlite3
          /usr/bin/ld: skipping incompatible /usr/lib/x86_64-linux-gnu/libsqlite3.a when searching for -lsqlite3
          /usr/bin/ld: cannot find -lsqlite3
          collect2: error: ld returned 1 exit status
error: aborting due to previous error
error: Could not compile `netlyser`.
Caused by:
  process didn't exit successfully: `rustc --crate-name netlyser src/main.rs --color always --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=b65deb703a1f6236 -C extra-filename=-b65deb703a1f6236 --out-dir /home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/deps --target i686-unknown-linux-musl -C incremental=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/incremental -L dependency=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/deps -L dependency=/home/travis/build/Dentrax/Netlyser/target/debug/deps --extern chrono=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/deps/libchrono-1704a347ccb015cf.rlib --extern clap=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/deps/libclap-d4f2b963d38806ef.rlib --extern console=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/deps/libconsole-4015382a9b92883e.rlib --extern env_logger=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/deps/libenv_logger-0056f2899fae3fcc.rlib --extern lazy_static=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/deps/liblazy_static-c510b2dc9c7da186.rlib --extern log=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/deps/liblog-cdb71ae66673285d.rlib --extern netlyser=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/deps/libnetlyser-9abcce0fe9ef2dea.rlib --extern notify_rust=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/deps/libnotify_rust-a3a1feb682c4b0ad.rlib --extern pnet=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/deps/libpnet-7785acefe25fba00.rlib --extern regex=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/deps/libregex-57eb209a6e6f7630.rlib --extern rusqlite=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/deps/librusqlite-3a610f8e8a961a30.rlib --extern serde=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/deps/libserde-96302cb691af04b3.rlib --extern serde_xml_rs=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/deps/libserde_xml_rs-5275ad59a7ca4bcd.rlib --extern serde_derive=/home/travis/build/Dentrax/Netlyser/target/debug/deps/libserde_derive-143ecae19981d119.so --extern serde_yaml=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/deps/libserde_yaml-1f427a9eba6f481f.rlib --extern tempfile=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/deps/libtempfile-9a2052bcd29665f8.rlib -L native=/usr/lib/x86_64-linux-gnu -L native=/home/travis/build/Dentrax/Netlyser/target/i686-unknown-linux-musl/debug/build/backtrace-sys-333fff48593f7482/out` (exit code: 1)
The command "cargo build --target $TARGET --verbose" exited with 101.

@diwic
Copy link
Owner

diwic commented May 11, 2019

Let's try without pkg-config instead. Could you try putting something like this in your .cargo/config :

[target.armv7-unknown-linux-gnueabihf.dbus]
rustc-link-search = ["putyourlibshere"]
rustc-link-lib = ["dbus-1"]

[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc-8"

...replace arm-linux-gnueabihf-gcc-8 with your cross compiler version, and putyourlibshere with wherever you've installed your target libraries.

See https://doc.rust-lang.org/cargo/reference/build-scripts.html#overriding-build-scripts

Also if you get this to work could you help me documenting it for the next person who wants to cross compile dbus-rs?

@diwic
Copy link
Owner

diwic commented May 11, 2019

Also there is a reddit thread here: https://www.reddit.com/r/rust/comments/bn0xn1/trying_to_cross_compile_for_32_bit_system_from_64/
...that looks what you're trying to do, maybe you are the same person as that reddit poster?

@Dentrax
Copy link
Author

Dentrax commented May 11, 2019

@diwic No, I am not that person. :)

I tried what you said. And now I am getting this:

error: linker x86_64-linux-musl-gcc not found

Is my .cargo/config file correct?

[target.i686-unknown-linux-musl.dbus]
rustc-link-search = ["/usr/lib/x86_64-linux-gnu/libdbus-1.so"]
rustc-link-lib = ["dbus-1"]

[target.i686-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"

Should I just use musl-gcc or something like that?

Project: https://github.com/Dentrax/Netlyser
Also you can check Travis here: https://travis-ci.org/Dentrax/Netlyser/builds/531214406

This bug bothers me now and I don't want to challenge it anymore. :(

@diwic
Copy link
Owner

diwic commented May 16, 2019

@Dentrax I've started to write some cross compilation instructions, but I can't get it to work myself. I'm closing this bug in favor of #184

@diwic diwic closed this as completed May 16, 2019
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

2 participants