Ogeon / rust-on-raspberry-pi

[OUTDATED] Instructions for how to cross compile Rust projects for the Raspberry Pi
292 stars 15 forks source link

Unable to Extract .deb file for the SSL #18

Open ghost opened 8 years ago

ghost commented 8 years ago

hello, im a student and is curently learning rust and im also new to linux, and i want to compile my code so that it can run on a raspberry pi 3. my project uses some crate that depends on having openssl. i followed your instruction, downloaded .deb file from http://ftp.debian.org/debian/pool/main/o/openssl/libssl1.0.0_1.0.1k-3+deb8u4_armhf.deb. but when i try to extract the file using this command kenichi@kenichi-Aspire-E5-473G:~/pi-tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/arm-bcm2708hardfp-linux-gnueabi/sysroot$ ar p libssl1.0.0_1.0.1k-3+deb8u4_armhf.deb data.tar.gz | tar zx i get this error

no entry data.tar.gz in archive gzip: stdin: unexpected end of file tar: Child returned status 1 tar: Error is not recoverable: exiting now

what am i supposed to do to get around this problem? thanks in advance.

Ogeon commented 8 years ago

Hmm, yeah, you are right. Something must have changed since that part was written, so that'll have to be rewritten. In any case, you should be able to unpack it with dpkg -x archive.deb target_dir/, if you have dpkg installed. Just replace target_dir with the Raspberry Pi sysroot directory.

They are otherwise just compressed archives, so your favorite archive manager should be able to read it.

Ping @tfnico.

ghost commented 8 years ago

thank you for the reply. somehow i managed to unpack it. and the dependency is now solved but im having a different problem now. something like this:

error: linking with gcc-sysroot failed: exit code: 1

what does this error mean? i have no idea what's wrong i followed your instruction from top to bottom. can you help me with this?

this is what's inside my config file in the .cargo directory

[target.arm-unknown-linux-gnueabihf] ar = "arm-linux-gnueabihf-gcc-ar" linker = "gcc-sysroot"

and this is what's inside gcc-sysroot file in the /home/kenichi/pi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin directory

!/bin/bash

arm-linux-gnueabihf-gcc --sysroot=$HOME/pi-tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/arm-bcm2708hardfp-linux-gnueabi/sysroot "$@"

and made the file executable using chmod command. one more question, do i need to have a nightly version of Rust 'cause i currently have a stable version? thank you for the help.

Ogeon commented 8 years ago

what does this error mean? i have no idea what's wrong i followed your instruction from top to bottom. can you help me with this?

It means that something went wrong, nut it's hard to say what from just an exit code. Did it print anything more? Did you try to run it in verbose mode (with -v or --verbose flag) to get any more info?

one more question, do i need to have a nightly version of Rust 'cause i currently have a stable version?

That shouldn't matter.

ghost commented 8 years ago

this is the whole error using verbose mode

error: linking with gcc-sysroot failed: exit code: 1 note: "gcc-sysroot" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-L" "/home/kenichi/pi-rust/lib/rustlib/arm-unknown-linux-gnueabihf/lib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/rustberry.0.o" "-o" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/rustberry" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "-L" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug" "-L" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps" "-L" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/build/openssl-8f82a1ac7a7f09d7/out" "-L" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/build/openssl-sys-extras-6cdd9aaab3f99a18/out" "-L" "/home/kenichi/pi-rust/lib/rustlib/arm-unknown-linux-gnueabihf/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libhyper-21c6f5ecb796d860.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libopenssl_verify-ff07e935c578a429.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libhttparse-9ed9b694220e1406.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libnum_cpus-58f3e3070ab6aa63.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libcookie-b2e1d689a1ae5738.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/librustc_serialize-3bc953984ed46e7f.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/liburl-3c116f81be85494f.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libidna-cfd533a97becc7e1.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libunicode_bidi-7a56a7dec369a022.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libopenssl-8520cc35dff6bf9e.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libbitflags-10d625c8a1ca3e9d.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libopenssl_sys_extras-ecdbfecdf6d02bbf.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libunicode_normalization-f33127ef3e902b05.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libtraitobject-3d4dcec5d1662e96.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libtime-71756e48b8b5b73b.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libtypeable-1604229584d39a42.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/liblazy_static-a81b08a56ec46bff.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libmatches-030a774745cc4f96.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libopenssl_sys-d6cc5beb50faec31.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/liblanguage_tags-1cb52046c41cf66a.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libunicase-2e75ae83bf996d47.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libmime-70929d5d5f4a3c77.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libsolicit-8f0dfee0deffeb96.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libhpack-320332c60c4dfc72.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/liblog-342ffb7444a9471d.rlib" "/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/liblibc-38919d24e617a235.rlib" "/home/kenichi/pi-rust/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libstd-9026086f.rlib" "/home/kenichi/pi-rust/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libcollections-9026086f.rlib" "/home/kenichi/pi-rust/lib/rustlib/arm-unknown-linux-gnueabihf/lib/librustc_unicode-9026086f.rlib" "/home/kenichi/pi-rust/lib/rustlib/arm-unknown-linux-gnueabihf/lib/librand-9026086f.rlib" "/home/kenichi/pi-rust/lib/rustlib/arm-unknown-linux-gnueabihf/lib/liballoc-9026086f.rlib" "/home/kenichi/pi-rust/lib/rustlib/arm-unknown-linux-gnueabihf/lib/liballoc_jemalloc-9026086f.rlib" "/home/kenichi/pi-rust/lib/rustlib/arm-unknown-linux-gnueabihf/lib/liblibc-9026086f.rlib" "/home/kenichi/pi-rust/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libcore-9026086f.rlib" "-l" "ssl" "-l" "crypto" "-l" "util" "-l" "dl" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "util" "-l" "compiler-rt" note: /home/kenichi/pi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: /home/kenichi/pi-tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/arm-bcm2708hardfp-linux-gnueabi/sysroot/usr/lib/arm-linux-gnueabihf/libssl.a(s23_meth.o): relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC /home/kenichi/pi-tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/arm-bcm2708hardfp-linux-gnueabi/sysroot/usr/lib/arm-linux-gnueabihf/libssl.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status

error: aborting due to previous error error: Could not compile rustberry.

Caused by: Process didn't exit successfully: rustc src/main.rs --crate-name rustberry --crate-type bin -g --out-dir /home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug --emit=dep-info,link --target arm-unknown-linux-gnueabihf -C ar=arm-linux-gnueabihf-gcc-ar -C linker=gcc-sysroot -L dependency=/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug -L dependency=/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps --extern hyper=/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/libhyper-21c6f5ecb796d860.rlib --extern rustc_serialize=/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/deps/librustc_serialize-3bc953984ed46e7f.rlib -L native=/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/build/openssl-8f82a1ac7a7f09d7/out -L native=/home/kenichi/Documents/Projects/Rust/rustberry/target/arm-unknown-linux-gnueabihf/debug/build/openssl-sys-extras-6cdd9aaab3f99a18/out (exit code: 101)

Ogeon commented 8 years ago

note: /home/kenichi/pi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: /home/kenichi/pi-tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/arm-bcm2708hardfp-linux-gnueabi/sysroot/usr/lib/arm-linux-gnueabihf/libssl.a(s23_meth.o): relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC

Looks like this is it. A quick search points towards it expecting a dynamic library, but finding a static one (or something like that). There may be a libssl.so.[some numbers] somewhere in there that you can symlink to libssl.so. I would try that.

ghost commented 8 years ago

i found a libssl.so.1.0.0 file in this directory /lib/x86_64-linux-gnu/ is this the one you're referring to??

where should i put the created symlink? 'cause from what i have read the syntax for creating a symbolic link is ln -s <source> <destination> where should i put the symbolic link?

thank you. i really appreciate your help.

Ogeon commented 8 years ago

i found a libssl.so.1.0.1 file in this directory /lib/x86_64-linux-gnu/ is this the one you're referring to??

That one is for your host system (x86_64). The one you are looking for should be in your Raspberry Pi sysroot, if anywhere. Peeking into the .deb shows that it's called libssl.so.1.0.0.

where should i put the created symlink? 'cause from what i have read the syntax for creating a symbolic link is ln -s <source> <destination> where should i put the symbolic link?

That's correct. You can create it in the same directory as the file you are linking to, or just anywhere where gcc-sysroot can find it (i.e. wherever there are other library files).

ghost commented 8 years ago

i got a different error now:

note: /home/kenichi/pi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: warning: ld-linux-armhf.so.3, needed by /home/kenichi/pi-tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/arm-bcm2708hardfp-linux-gnueabi/sysroot/usr/lib/arm-linux-gnueabihf/libssl.so, not found (try using -rpath or -rpath-link) /home/kenichi/pi-rust/lib/rustlib/arm-unknown-linux-gnueabihf/lib/liballoc_jemalloc-9026086f.rlib(jemalloc.pic.o): In function malloc_conf_init': /home/kenichi/rust/src/jemalloc/src/jemalloc.c:937: undefined reference tosecure_getenv' collect2: error: ld returned 1 exit status

Ogeon commented 8 years ago

Looks like it's unable to find the function secure_getenv, which seems strange. It should be in the C standard library. I have seen someone have the problem before, but I think the reason was that they didn't have the correct environment set up. Did you use any of the crossXX scripts? They are setting up some pretty important environment variables.

ghost commented 8 years ago

yeah. im using the cross64 script.

Ogeon commented 8 years ago

Ok. I don't know what the reason for the problem is, to be honest. I'll have to try to reproduce it, myself, and do some experiments, but that'll have to wait until later.

ghost commented 8 years ago

okay, i really appreciate your help. thanks a lot..

ghost commented 8 years ago

update on the error. i somehow manage to minimize the error. now this is the only error.

note: /home/kenichi/pi-rust/lib/rustlib/arm-unknown-linux-gnueabihf/lib/liballoc_jemalloc-9026086f.rlib(jemalloc.pic.o): In function malloc_conf_init': /home/kenichi/rust/src/jemalloc/src/jemalloc.c:937: undefined reference tosecure_getenv' collect2: error: ld returned 1 exit status

ghost commented 8 years ago

UPDATE: i can now compile it without any error. i just downloaded other dependencies and installed them in the sysroot for the Raspberry PI. these are the dependencies i installed

libc6-udeb_2.19-18+deb8u4_armhf.udeb linux-libc-dev_3.16.7-ckt25-1_armhf.deb libc-dev-bin_2.19-18+deb8u4_armhf.deb perl-base_5.20.2-3+deb8u4_armhf.deb debconf_1.5.56_all.deb gcc-4.9-base_4.9.2-10_armhf.deb libgcc1_4.9.2-10_armhf.deb libc6_2.19-18+deb8u4_armhf.deb multiarch-support_2.19-18+deb8u4_armhf.deb zlib1g_1.2.8.dfsg-2+b1_armhf.deb zlib1g-dev_1.2.8.dfsg-2+b1_armhf.deb libssl1.0.0_1.0.1k-3+deb8u5_armhf.deb libssl-dev_1.0.1k-3+deb8u5_armhf.deb

thank you for the help @Ogeon . much appreciated.

Ogeon commented 8 years ago

Great! I'll keep this issue open until this section of the guide has been rewritten.