Arm cortex-a9 cross compile sharing
fatalfeel opened this issue · comments
-
check NEON flag
/opt/compiler/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ -dM -E - < /dev/null
default flag ARM_NEON for old compiler or __ARM_NEON for new compiler
if there is no ARM_NEON or __ARM_NEON then add it
cd dlib
gedit ./toolchain.make
set( CMAKE_SYSTEM_NAME Linux )
set( CMAKE_SYSTEM_PROCESSOR arm )
set( CMAKE_C_COMPILER /opt/compiler/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc )
set( CMAKE_CXX_COMPILER /opt/compiler/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ )
mkdir -p _mpsoc
cd _mpsoc
#must add -mfpu=neon or compile error
cmake .. -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.make -DCMAKE_INSTALL_PREFIX=/opt/arm/dlib -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="-D__ARM_NEON__ -D__ARM_NEON -mfpu=neon -O3 -g" -DCMAKE_CXX_FLAGS_RELEASE="-D__ARM_NEON__ -D__ARM_NEON -mfpu=neon -O3 -g" -DDLIB_USE_CUDA=OFF -DUSE_NEON_INSTRUCTIONS=ON
if compile error refer to
#2574
#create App
gedit Makefile
CXX=/opt/compiler/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++
CXXFLAGS=-I/opt/arm/dlib/include -I/opt/arm/opencv/include -D__ARM_NEON__ -D__ARM_NEON -mfpu=neon -O3 -g -fPIC -pthread -fmessage-length=0 -std=c++14
LDFLAGS=-L/opt/arm/dlib/lib -L/opt/arm/opencv/lib -Wl,-rpath,. -ldlib -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lopencv_videoio -lpthread
OBJS=nt_infer_object_detector.o
TARGET=nt_infer_object_detector
all: $(TARGET)
clean:
rm -f
#if you need opencv download opencv 3.4.16
mkdir -p build
cd build
cmake .. -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.make -DCMAKE_INSTALL_PREFIX=/opt/arm/opencv -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE="-D__ARM_NEON__ -D__ARM_NEON -mfpu=neon -O3 -g" -DCMAKE_CXX_FLAGS_RELEASE="-D__ARM_NEON__ -D__ARM_NEON -mfpu=neon -O3 -g" -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF -DWITH_GSTREAMER=OFF -DWITH_CUDA=OFF -DENABLE_NEON=ON -DENABLE_VFPV3=ON
cmake --build . --config Release --target install -- -j$CPU_NUM VERBOSE=1