目錄
原始碼來源
https://github.com/projectNe10/Ne10
目標平台
- Arm
- armv7
修改GNUlinux_config.cmake
-
可以在開頭補上兩個變數,避免編譯測試:
set(CMAKE_C_COMPILER_FORCED TRUE) set(CMAKE_CXX_COMPILER_FORCED TRUE) set(GNULINUX_PLATFORM ON) set(CMAKE_SYSTEM_NAME "Linux") set(CMAKE_SYSTEM_PROCESSOR "arm")
-
設定"armv7"的編譯器路徑:
if(NE10_LINUX_TARGET_ARCH STREQUAL "armv7") set(MYSYSROOT "/path/toolchain/x86_64-ca9v1-tc14-toolchain-9.0/sysroots/ca9v1-starfishmllib32-linux-gnueabi") set(CMAKE_C_COMPILER "/path/toolchain/x86_64-ca9v1-tc14-toolchain-9.0/sysroots/x86_64-starfishsdk-linux/usr/bin/arm-starfish-linux-gnueabi/arm-starfish-linux-gnueabi-gcc") set(CMAKE_CXX_COMPILER "/path/toolchain/x86_64-ca9v1-tc14-toolchain-9.0/sysroots/x86_64-starfishsdk-linux/usr/bin/arm-starfish-linux-gnueabi/arm-starfish-linux-gnueabi-g++") set(CMAKE_ASM_COMPILER "/path/toolchain/x86_64-ca9v1-tc14-toolchain-9.0/sysroots/x86_64-starfishsdk-linux/usr/bin/arm-starfish-linux-gnueabi/arm-starfish-linux-gnueabi-as") find_program(CMAKE_AR NAMES "arm-starfish-linux-gnueabi-ar" PATHS "/home2/bowuns/source/k8/kernel/system/tmp/toolchain/x86_64-ca9v1-tc14-toolchain-9.0/sysroots/x86_64-starfishsdk-linux/usr/bin/arm-starfish-linux-gnueabi/" NO_DEFAULT_PATH) find_program(CMAKE_RANLIB NAMES "arm-starfish-linux-gnueabi-ranlib" PATHS "/home2/bowuns/source/k8/kernel/system/tmp/toolchain/x86_64-ca9v1-tc14-toolchain-9.0/sysroots/x86_64-starfishsdk-linux/usr/bin/arm-starfish-linux-gnueabi/" NO_DEFAULT_PATH)
-
對於linux x86_64本機的編譯器路徑則可如下表示:
if(NE10_LINUX_TARGET_ARCH STREQUAL "armv7") set(MYSYSROOT "/usr/arm-linux-gnueabihf/") set(CMAKE_C_COMPILER "/usr/bin/arm-linux-gnueabihf-gcc") set(CMAKE_CXX_COMPILER "/usr/bin/arm-linux-gnueabihf-g++") set(CMAKE_ASM_COMPILER "/usr/bin/arm-linux-gnueabihf-as") find_program(CMAKE_AR NAMES "arm-linux-gnueabihf-ar" PATHS "/usr/bin/" NO_DEFAULT_PATH) find_program(CMAKE_RANLIB NAMES "arm-linux-gnueabihf-ranlib" PATHS "/usr/bin/" NO_DEFAULT_PATH)
-
修改CMakelists.txt
-
將參數改為ON,建置Share Object:
option(NE10_BUILD_SHARED "Build NE10 shared libraries" ON)
-
選擇預期的模式 (Optional),這裡使用預設值:
option(NE10_ARM_HARD_FLOAT "Build NE10 for hard float abi" ON)
-
修改GNULINUX_PLATFORM的編譯參數:
if("${NE10_TARGET_ARCH}" STREQUAL "armv7") set(FLOAT_ABI "softfp") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=${MYSYSROOT} -mthumb -march=armv7-a -mfloat-abi=${FLOAT_ABI} -mfpu=vfp3 -funsafe-math-optimizations") set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} -mthumb -march=armv7-a -mfpu=neon") # Turn on asm optimization for Linux on ARM v7. set(NE10_ASM_OPTIMIZATION on) endif()
- 這裡強制將armv7的
FLOAT_ABI
設為"softfp"
,也可以透過前一個步驟的方式來設定
- 這裡強制將armv7的
執行編譯
cd $NE10_PATH
mkdir build && cd build
export NE10_LINUX_TARGET_ARCH=armv7
cmake -DCMAKE_TOOLCHAIN_FILE=../GNUlinux_config.cmake ..
make
comments powered by Disqus