0

I can't find the answers so I am asking here.

I use Linaro 64bit ARM cross compiler to compile my code on a local Ubuntu 14.04 64bit Linux on Intel (gcc-linaro-5.3-2016.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++).

My code requires to use libsensor4 and libsensor4-dev with linker option -lsensors. I have no problem compiling my code using the 64bit Ubuntu 14.04 host Linux on Intel. But every time I compile my code using the 64bit ARM cross compiler it has errors:

cannot find -lsensors

and

sensors/sensors.h: no such file or directory.

The -lsensors is from libsensors4.deb and the sensors.h is from libsensors4-dev. so how can I get those two packages into the Linaro cross compiler?

0

One way to get aarch64 packages into the build system is to enable it as a foreign architecture:

sudo dpkg --add-architecture aarch64
sudo apt-get update

Now you can remove libsensors4-dev for your build architecture and install it for the host architecture aarch64:

sudo apt-get install libsensors4-dev- libsensors4-dev:aarch64+

It's necessary to remove the build architecture package because it can't coexist with a package of the same name for a different architecture. The dependency libsensors4:aarch64 however can coexist with libsensors41. This means that you can keep running programs on the build system that are dynamically linked against libsensors4 but you can't use libsensors4-dev to link new build architecture programs against it.

I don't know how you configured and installed the cross-compiler but GCC usually picks up the canonical locations for header files (/usr/include) and library files (/usr/lib/<architecture>-<system-type>) which is exactly to where DPKG extracts them from libsensors4-dev (any architecture). If that's not the case you can tell GCC/G++ to add include file directories with -I<PATH> and library directories with -L<PATH>. Furthermore you can list current include directories with gcc -xc++ -E -v /dev/null and current library directories with gcc gcc -print-search-dirs.


1 You can check if a package can coexist with its “sibling” of a different architecture if you look at Multi-Arch field in the package control information. “same” means it can coexist. Use dpkg-query -s <PACKAGE>, apt-cache show <PACKAGE>, or dpkg-deb -I <DEB-FILE> to show package control information. For more info see the Multiarch Specification on Binary package control fields.

  • But how does the Linaro 64bit cross compiiler know there are two aarch64 dev packages on the 32 bit host machine? – alien Apr 13 '17 at 13:43
  • When you say aarch64 can coexist with the 32bit aarch does that mean I have to unstall the original 32bit aarch package first then install the aarch64? if the 32 bit aarch package is uninstalled can the aarch64 package be used for 32bit app too? – alien Apr 13 '17 at 14:22
  • Thanks for the input. I can get use -I (Include) for additional include path to resolve the header file error. but how does the cross compiler know the -lsensors?? i still got this cannot find -lsensors error. I did not set up the cross compiler at all. I only installed it to a directory (/opt) and my application uses g++ from that /opt directory to compile my code for cross compiling – alien Apr 13 '17 at 15:02
  • I added more info on compiler and linker search paths. – David Foerster Apr 13 '17 at 15:16
  • my mistake. i actually have a 64 bit Ubuntu 14.04 Linux with Intel as the host PC and the target machine has a Ubuntu 16.04 Linux with ARM. Do I need to do the same multi arch thing above to let the ARM cross compiler recognize the -lsensor library in /usr/lib of the Intel 64bit host machine? – alien Apr 13 '17 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.