0

I'm following the answer in this question (Installing Raspberry Pi Cross-Compiler) to set up a a toolchain to compile from linux (Mint 18.1) to a raspberry pi 3.

I set everything up but when I make my project, it cannot find headers that I see are indeed copied in my local machine.

For example,

My cmake cross compile toolchain file for the project looks like this:

SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_C_COMPILER $ENV{HOME}/workspace/pi/xtools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER $ENV{HOME}/workspace/pi/xtools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-g++)
SET(CMAKE_FIND_ROOT_PATH $ENV{HOME}/workspace/pi/pilibs/)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  • $HOME/workspace/pi/xtools is the git://github.com/raspberrypi/tools.git repo.
  • $HOME/workspace/pi/pilibs contains my pi's /lib and /usr dirs. And I can confirm if I 'make' the program directly on the pi, it compiles fine.

But when I 'make' on my Linux box, after generating the makefiles with cmake (using cmake-qt-gui; selecting the above toolchain file), it can't find headers:

fede@fede-mbp ~/workspace/mt/mt-build-pi $ make
Scanning dependencies of target cguittfont
[  0%] Building CXX object src/cguittfont/CMakeFiles/cguittfont.dir/xCGUITTFont.cpp.o
In file included from /home/fede/workspace/pi/xtools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/cstdlib:72:0,
                from /home/fede/workspace/pi/xtools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/bits/stl_algo.h:59,
                from /home/fede/workspace/pi/xtools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/include/c++/4.8.3/algorithm:62,
                from /home/fede/workspace/mt/minetest/src/cguittfont/xCGUITTFont.h:4,
                from /home/fede/workspace/mt/minetest/src/cguittfont/xCGUITTFont.cpp:4:
/home/fede/workspace/pi/pilibs/usr/include/stdlib.h:760:34: fatal error: bits/stdlib-bsearch.h: No such file or directory
# include <bits/stdlib-bsearch.h>
                                ^
compilation terminated.

Although I do have /home/fede/workspace/pi/pilibs/usr/include/arm-linux-gnueabihf/bits/stdlib-bsearch.h

Community
  • 1
  • 1
SaldaVonSchwartz
  • 3,769
  • 2
  • 41
  • 78
  • Looks like `/home/fede/workspace/pi/pilibs/usr/include/arm-linux-gnueabihf/` is not in your include path. As far as I understand, paths with compiler-specific suffixes are in include path only when they are come with compiler (toolchain) itself. But you toolchain is under completely different directory, so why it should use that path? As for path `/home/fede/workspace/pi/pilibs/usr/include/`, I guess it is searched only because some `find_path()` call has found it. This command uses *CMAKE_FIND_ROOT_PATH* variable, but the compiler itself is unaware of it. – Tsyvarev Mar 25 '17 at 21:08

1 Answers1

0

Apparently, I had to also set CMAKE_SYSROOT to the same path as CMAKE_FIND_ROOT_PATH.

SaldaVonSchwartz
  • 3,769
  • 2
  • 41
  • 78