Wrong path when linking


#1

I try cross compiling my gui programm, and get the error:

error: linking with `arm-linux-gnueabihf-gcc` failed: exit code: 1
note: "arm-linux-gnueabihf-gcc" "-Wl,--as-needed" "-L" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib" "/home/chessnokov/workspace/src/gui/target/arm-unknown-linux-gnueabihf/debug/gui.0.o" "-o" "/home/chessnokov/workspace/src/gui/target/arm-unknown-linux-gnueabihf/debug/gui" "-Wl,--whole-archive" "-l" "morestack" "-Wl,--no-whole-archive" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "/home/chessnokov/workspace/src/gui/target/arm-unknown-linux-gnueabihf/debug/deps/libgdk-8ae980122de3e0e0.rlib" "/home/chessnokov/workspace/src/gui/target/arm-unknown-linux-gnueabihf/debug/deps/libcairo-1643c38463227c0b.rlib" "/home/chessnokov/workspace/src/gui/target/arm-unknown-linux-gnueabihf/debug/deps/libgdk_sys-ed787518fa614e91.rlib" "/home/chessnokov/workspace/src/gui/target/arm-unknown-linux-gnueabihf/debug/deps/libcairo_sys-92c4ac71c21762d5.rlib" "/home/chessnokov/workspace/src/gui/target/arm-unknown-linux-gnueabihf/debug/deps/libgdk_pixbuf_sys-f41c681dc2da5540.rlib" "/home/chessnokov/workspace/src/gui/target/arm-unknown-linux-gnueabihf/debug/deps/libglib-c30dcc353c5e2e1f.rlib" "/home/chessnokov/workspace/src/gui/target/arm-unknown-linux-gnueabihf/debug/deps/libgio_sys-2e4cc1abda621323.rlib" "/home/chessnokov/workspace/src/gui/target/arm-unknown-linux-gnueabihf/debug/deps/libpango_sys-a7f411582d25f0ec.rlib" "/home/chessnokov/workspace/src/gui/target/arm-unknown-linux-gnueabihf/debug/deps/libgobject_sys-1af98584dffb2ff9.rlib" "/home/chessnokov/workspace/src/gui/target/arm-unknown-linux-gnueabihf/debug/deps/libglib_sys-de2f35c439d686b9.rlib" "/home/chessnokov/workspace/src/gui/target/arm-unknown-linux-gnueabihf/debug/deps/liblibc-144c435538abd757.rlib" "/home/chessnokov/workspace/src/gui/target/arm-unknown-linux-gnueabihf/debug/deps/libbitflags-c495827ddcd6a202.rlib" "/home/chessnokov/workspace/src/gui/target/arm-unknown-linux-gnueabihf/debug/deps/libc_vec-944f3e3f45efffaf.rlib" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libstd-7e44814b.rlib" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libcollections-7e44814b.rlib" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/librustc_unicode-7e44814b.rlib" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/librand-7e44814b.rlib" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/liballoc-7e44814b.rlib" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/liblibc-7e44814b.rlib" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib/libcore-7e44814b.rlib" "-L" "/home/chessnokov/workspace/src/gui/target/arm-unknown-linux-gnueabihf/debug" "-L" "/home/chessnokov/workspace/src/gui/target/arm-unknown-linux-gnueabihf/debug/deps" "-L" "/usr/lib64" "-L" "/usr/lib64" "-L" "/usr/lib64" "-L" "/usr/lib64" "-L" "/usr/lib64" "-L" "/usr/lib64" "-L" "/usr/lib64" "-L" "/usr/local/lib/rustlib/arm-unknown-linux-gnueabihf/lib" "-L" "/home/chessnokov/workspace/src/gui/.rust/lib/arm-unknown-linux-gnueabihf" "-L" "/home/chessnokov/workspace/src/gui/lib/arm-unknown-linux-gnueabihf" "-Wl,-Bstatic" "-Wl,-Bdynamic" "-l" "gdk-3" "-l" "pangocairo-1.0" "-l" "pango-1.0" "-l" "gdk_pixbuf-2.0" "-l" "cairo-gobject" "-l" "cairo" "-l" "gobject-2.0" "-l" "glib-2.0" "-l" "cairo" "-l" "gdk_pixbuf-2.0" "-l" "gobject-2.0" "-l" "glib-2.0" "-l" "gio-2.0" "-l" "gobject-2.0" "-l" "glib-2.0" "-l" "pango-1.0" "-l" "gobject-2.0" "-l" "glib-2.0" "-l" "gobject-2.0" "-l" "glib-2.0" "-l" "glib-2.0" "-l" "c" "-l" "m" "-l" "dl" "-l" "pthread" "-l" "rt" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "compiler-rt"
note: /usr/lib64/libgdk-3.so: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status

Why cargo put /usr/lib64 instead /usr/lib/arm-linux-gnueabihf?


#2

Like I explained on gitter, the build script calls pkg-config, among other reasons, to find out the installed library version, and that’s where -L/usr/lib64 comes from (I believe). Try removing the use of pkg-config in the build scripts and hardcoding the version, to see how much further you’ll get.


#3

i set up PKG_CONFIG_SYSROOT_DIR,
and check pkg-config:

pkg-config --libs gio-2.0
-L/run/media/chessnokov/rootfs/usr/lib/arm-linux-gnueabihf -lgio-2.0 -lgobject-2.0 -lglib-2.0

but cargo still put “lib64”


#4

This will move quicker if you open an issue with the detailed steps to reproduce from scratch.


#5

Maybe problem not in gtk package?
I think problem in pkg-config package.
I will try to sort out the problem in more detail , and then open an issue.


#6

i remove all from project target folder,
and run

PKG_CONFIG_ALLOW_CROSS=1 PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig cargo build --target=arm-unknown-linux-gnueabihf

all compiled succesfull

My mistake was that the first time I compile a program without specifying a triple-target.
It turns out that the cargo does not track the change of triple-target:
and if deps already compiled , then it not recompile.


#7

Does your cargo not put the cross-compiled files into target/arm-unknown-linux-gnueabihf when you specify the target?


#8

I guess I’m not exactly put, i try again:

My mistake was that the first time I compile a program without specifying a

PKG_CONFIG_ALLOW_CROSS=1 PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig

and rust libs(gtk) linked to native(64-bits) c libs,

but after i put pkg-config env, cargo does not recompile gtk(and other) pakage.


#9

Yeah, it doesn’t know how to keep track of any env variables that might influence the build scripts.