- 在x264的源码文件夹下 /configure --prefix=/home/phoenix/document/hisiv3519/x264_hi3519 --enable-shared --enable-static --host=arm-hisiv500-linux --disable-asm
修改config.mak
Sudo gedit config.mak
主要将:
CC=gcc
改为 CC=arm-hisiv500-linux-gcc
LD=gcc -o
改为 LD=arm-hisiv500-linux-gcc -o
RANLIB=ranlib
改为 RANLIB=arm-hisiv500-linux-ranlib
STRIP=strip
改为 STRIP=arm-hisiv500-linux-strip
make的时候出现错误:
common/rectangle.h: In function ‘x264_macroblock_cache_rect’:
common/rectangle.h:84: error: ‘v4si’ undeclared (first use in this function)
common/rectangle.h:84: error: (Each undeclared identifier is reported only once
common/rectangle.h:84: error: for each function it appears in.)
common/rectangle.h:84: error: expected ‘;’ before ‘v16’
common/rectangle.h:86: error: ‘__m128’ undeclared (first use in this function)
common/rectangle.h:86: error: expected ‘;’ before ‘v16’
make: *** [x264.o] Error 1
在网上各种搜索也没找到所以然,想起来之前用基于hisiv600工具链编译是成功的,就像是不是出在编译链上,然后看到文件里说:使用某一工具链编译后,如果需要更换工具链,请先将原工具链编译文件清除,然后再更换工具链编译。所以将/etc/profile里面关于hisiv600的路径注释掉,再source /etc/profile ,用命令arm+回车发现hisiv600的工具链仍然存在,然后重启虚拟机,只剩hisiv500的工具链,重新编译x264,成功
2.编译ffmpeg
./configure --prefix=/home/phoenix/document/hisiv3519/ffmpeg_hi3519 --enable-static --enable-cross-compile --arch=arm --target-os=linux --cc=arm-hisiv500-linux-gcc --enable-libx264 --enable-gpl --enable-pthreads --disable-stripping --ar=arm-hisiv500-linux-ar --ld=arm-hisiv500-linux-gcc --strip=arm-hisiv500-strip --extra-cflags=-I/home/phoenix/document/hisiv3519/x264_hi3519/include --extra-ldflags=L/home/phoenix/document/ hisiv3519/ x264_hi3519/lib
make
make install
3.编译opencv
如下图,operation stystem和version processor随便写,编译器分别选择gcc和g++,编译器的目录在/opt/hisi-linux/x86-arm/arm-hisiv500-linux/target/bin/arm-hisiv500-linux-gcc,targetroot选择arm-linux编译器的头文件目录,我这里是/opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/usr/include/。点击finish完成。
这个方法不行,直接按下面的步骤来吧
把/home/phoenix/document/hisiv3519/sourcecode/opencv-2.4.9/platforms/linux下面的arm-gnueabi.toolchain.cmake重命名为arm-hisiv500-linux.toolchain.cmake,把它所有东西删掉,并修改内容
set( CMAKE_SYSTEM_NAME Linux )
set( CMAKE_SYSTEM_PROCESSOR arm )
set( CMAKE_C_COMPILER arm-hisiv500-linux-gcc ) set( CMAKE_CXX_COMPILER arm-hisiv500-linux-g++ )
按照官方教程,在opencv-2.4.9下建立一个build目录,cd进入源码目录,执行一下命令: cmake -DCMAKE_TOOLCHAIN_FILE=/home/phoenix/document/hisiv3519/sourcecode/opencv-2.4.9/platforms/ l i n ux/arm-hisiv500-linux.toolchain.cmake
过程中所出现的错误有:
- CMake Error: The source directory "/home/phoenix/document/hisiv3519/sourcecode/opencv-2.4.9/build" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI. 原因:在build目录下执行的命令 cmake -DCMAKE_TOOLCHAIN_FILE=/home/phoenix/ document/hisiv3519/ sourcecode/opencv-2.4.9/platforms/ linux/arm-hisiv500-linux.toolchain.cmake,应该在opencv源码目录下执行这条指令
- CMake Error at /usr/local/share/cmake-3.2/Modules/CMakeDetermineSystem.cmake:104 (message): Could not find toolchain file: ../platforms/linux/arm-hisiv500-linux.toolchain.cmake../ Call Stack (most recent call first):CMakeLists.txt:56 (project)
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file: /home/phoenix/document/hisiv3519/sourcecode/opencv-2.4.9/CMakeFiles/3.2.2/CMakeCXXCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file: /home/phoenix/document/hisiv3519/sourcecode/opencv-2.4.9/CMakeFiles/3.2.2/CMakeCCompiler.cmake
CMake Error at CMakeLists.txt:56 (project):
No CMAKE_CXX_COMPILER could be found.
Tell CMake where to find the compiler by setting 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.
CMake Error at CMakeLists.txt:56 (project):
No CMAKE_C_COMPILER could be found.
Tell CMake where to find the compiler by setting 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: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
原因:
在源代码下执行的是命令 cmake -DCMAKE_TOOLCHAIN_FILE=../platforms/linux/arm-hisiv500-linux. toolchain.cmake../ 被自己蠢哭了,那个../是要自己对照着路径修改补齐的,我直接粘贴复制的。
综上,应该在opencv的源码目录下建一个build目录,并在opencv的源码目录下执行指令 用cmake-gui打开opencv的源码目录下的CMakeCache.txt,参照前面的博客把一些用不到选项的去掉,修改安装目 录/home/phoenix/ docume nt/ hisiv3519/opencv_hi3519。然后 make和 make install。在/home/phoenix/document /hisiv3519/ opencv _hi3 519, 里面有库文件和头文件(后面的事实证明这一波操作还是错的)
- 在编译自己的程序的时候出现错误:/home/phoenix/document/hisiv3519/opencv_hi3519/ lib/ libopencv_imgproc.a :error adding symbols: 不可识别的文件格式 collect2: error: ld returned 1 exit status。 原因:说是不可识别的文件格式,那肯定是用错编译器了,打开CMakeCache.txt一看果不其然,后来想通了,我用的opencv的源码目录下的CMakeCache.txt,默认用的是编译器路径是/usr/bin/gcc. 终极正确操作应该是在 opencv的源码目录下新建build文件夹,在build下面执行下面的指令,真是,看了好多遍官网教程,都没注意到要用的两次源码目录 cmake -DCMAKE_TOOLCHAIN_FILE=/home/phoenix/document/hisiv3519/sourcecode/opencv-2.4.9/platforms /linux/arm-hisiv500-linux.toolchain.cmake(空格)/home/phoenix/document /hisiv3519/ sourcecode/opencv -2.4.9 然后,执行完这一句之后,在build下面会出现一个CMakeCache.txt,用cmake打开这个CMakeCache.txt,然后参照前面的博客把一些用不到选项的去掉,修改安装目 录/home/phoenix/ docume nt/ hisiv3519/opencv_hi3519。然后 make和 make install。