abhiTronix / raspberry-pi-cross-compilers

Latest GCC Cross Compiler & Native (ARM & ARM64) CI generated precompiled standalone toolchains for all Raspberry Pis. 🍇
https://sourceforge.net/projects/raspberry-pi-cross-compilers
GNU General Public License v3.0
594 stars 104 forks source link

Errors when trying to build Hello World project #78

Closed emptor8 closed 3 years ago

emptor8 commented 3 years ago

I'm seeing the following errors below when I try to build the Hello World project from here: https://github.com/abhiTronix/raspberry-pi-cross-compilers/wiki/Cross-Compiler-CMake-Usage-Guide-with-rsynced-Raspberry-Pi-32-bit-OS#cross-compiler-cmake-usage-guide-with-rsynced-raspberry-pi-32-bit-os

Do you know what could be wrong?

test@ubuntu:\~/cmake-test/build$ cmake -DCMAKE_TOOLCHAIN_FILE=~/cmake-test/PI.cmake -DCMAKE_BUILD_TYPE=Debug .. -- The C compiler identification is unknown -- The CXX compiler identification is unknown CMake Error at CMakeLists.txt:2 (project): The CMAKE_C_COMPILER:

~/cmake-test/tools/cross-pi-gcc-8.3.0-2/bin/arm-linux-gnueabihf-gcc

is not a full path to an existing compiler tool.

Tell CMake where to find the compiler by setting either the environment variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH.

CMake Error at CMakeLists.txt:2 (project): The CMAKE_CXX_COMPILER:

~/cmake-test/tools/cross-pi-gcc-8.3.0-2/bin/arm-linux-gnueabihf-g++

is not a full path to an existing compiler tool.

Tell CMake where to find the compiler by setting either the environment variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH.

-- Configuring incomplete, errors occurred! See also "/home/test/cmake-test/build/CMakeFiles/CMakeOutput.log". See also "/home/test/cmake-test/build/CMakeFiles/CMakeError.log".

abhiTronix commented 3 years ago

The CMAKE_C_COMPILER:

~/cmake-test/tools/cross-pi-gcc-8.3.0-2/bin/arm-linux-gnueabihf-gcc is not a full path to an existing compiler tool.

The CMAKE_CXX_COMPILER:

~/cmake-test/tools/cross-pi-gcc-8.3.0-2/bin/arm-linux-gnueabihf-g++ is not a full path to an existing compiler tool.

@jteng7

Did you checked if this file paths ~/cmake-test/tools/cross-pi-gcc-8.3.0-2/bin/arm-linux-gnueabihf-gcc and ~/cmake-test/tools/cross-pi-gcc-8.3.0-2/bin/arm-linux-gnueabihf-g++ exists or not?

You can check this by running:

~/cmake-test/tools/cross-pi-gcc-8.3.0-2/bin/arm-linux-gnueabihf-gcc --version
~/cmake-test/tools/cross-pi-gcc-8.3.0-2/bin/arm-linux-gnueabihf-g++ --version

And, check if all dependencies are installed: https://github.com/abhiTronix/raspberry-pi-cross-compilers/wiki/Cross-Compiler-CMake-Usage-Guide-with-rsynced-Raspberry-Pi-32-bit-OS#1-update-the-host-machine

Also, Follow the docs carefully.

emptor8 commented 3 years ago

Both paths exist: image

Also, I double-checked all dependencies are installed.

One thing I noticed in the docs is I had to create a CMakeLists.txt file, not CMakeList.txt file (note the plural) -- is that an error in the docs?

emptor8 commented 3 years ago

An update: I got it working!

Changes I had to make:

abhiTronix commented 3 years ago

In PI.cmake, I had to change the tools and rootfs_dir paths to point to the full path (i.e. replace the tilde with the actual path with the home directory). For example, set(tools /home/test/cmake-test/tools/cross-pi-gcc-8.3.0-2) works but set(tools ~/cmake-test/tools/cross-pi-gcc-8.3.0-2) does NOT work.

@jteng7 Aren't you running Linux?

In CMakeLists.txt, I had to change the second parameter of add_executable to main.cpp instead of foo.cpp, to match the file to compile

Thanks I'll change it.

abhiTronix commented 3 years ago

One thing I noticed in the docs is I had to create a CMakeLists.txt file, not CMakeList.txt file (note the plural) -- is that an error in the docs?

It should be CMakeLists.txt.

abhiTronix commented 3 years ago

@jteng7 Can you try set(tools $ENV{HOME}/cmake-test/tools/cross-pi-gcc-8.3.0-2) instead of set(tools /home/test/cmake-test/tools/cross-pi-gcc-8.3.0-2)?

abhiTronix commented 3 years ago

Thanks, Docs updated.

emptor8 commented 3 years ago

In PI.cmake, I had to change the tools and rootfs_dir paths to point to the full path (i.e. replace the tilde with the actual path with the home directory). For example, set(tools /home/test/cmake-test/tools/cross-pi-gcc-8.3.0-2) works but set(tools ~/cmake-test/tools/cross-pi-gcc-8.3.0-2) does NOT work.

@jteng7 Aren't you running Linux?

Yeah, but one wrinkle is I'm running Ubuntu through VMWare, so that might be a reason for the issues I'm seeing?

@jteng7 Can you try set(tools $ENV{HOME}/cmake-test/tools/cross-pi-gcc-8.3.0-2) instead of set(tools /home/test/cmake-test/tools/cross-pi-gcc-8.3.0-2)?

Thanks - using this works as well 👍