項目場景:
華為好望角AI攝像頭C系列的算法移植過程中,遇到cmake報錯
問題描述:
gcc: aarch64-himix100-linux-gcc
CMakeLists.txt文檔:
cmake_minimum_required(VERSION 3.14)
project(NNIE_tutorial)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_COMPILER /home/liuky/HDD_1/soft/aarch-linux-gnu/bin/aarch64-linux-gnu-g++)
set(CMAKE_C_COMPILER /home/liuky/HDD_1/soft/aarch-linux-gnu/bin/aarch64-linux-gnu-gcc)
include_directories(3rd_party/hisi/include)
include_directories(include)
file(GLOB SRCS
src/*.cpp
src/*.hpp
)
file(GLOB LIBS
libs/libsecurec.a)
add_executable(NNIE_tutorial ${SRCS})
target_link_libraries(NNIE_tutorial pthread m dl)
target_link_libraries(NNIE_tutorial ${LIBS})
注意:此處修改标紅位址,改成你自己的aarch64-linux-gnu-g++和aarch64-linux-gnu-gcc所在位址。
1、set(CMAKE_CXX_COMPILER /home/liuky/HDD_1/soft/aarch-linux-gnu/bin/aarch64-linux-gnu-g++)
2、set(CMAKE_C_COMPILER /home/liuky/HDD_1/soft/aarch-linux-gnu/bin/aarch64-linux-gnu-gcc)
在CMakeLists.txt所在目錄下,依次執行以下指令,
mkdir bin # 建立bin檔案夾,友善存放cmake生成的中間檔案
cd bin
cmake .. # ..是CMakeLists.txt所在
報錯
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):
No CMAKE_C_COMPILER could be found.
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):
No CMAKE_CXX_COMPILER could be found.
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/HuaweiAI/nnie_sdc_tutorial/Part_3/bin/CMakeFiles/CMakeOutput.log".
See also "/home/HuaweiAI/nnie_sdc_tutorial/Part_3/bin/CMakeFiles/CMakeError.log".
解決方案:
1、确認 aarch64-himix100-linux-gcc安裝上了,執行如下指令
aarch64-himix100-linux-gcc -v
如果正确安裝,則輸出gcc version。
2、依次執行以下指令,更新依賴
sudo apt-get update
sudo apt-get install -y build-essential
此時再cmake,則成功,如下
[email protected]:/home/HuaweiAI/nnie_sdc_tutorial/Part_3/bin# cmake ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/HuaweiAI/nnie_sdc_tutorial/Part_3/bin