海思3519 arm-hisiv500-linux-交叉編譯x264、ffmpeg1.2.12、opencv2.4.9

  1. 在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


過程中所出現的錯誤有:

  1. 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源碼目錄下執行這條指令          
  2. 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, 裏面有庫文件和頭文件(後面的事實證明這一波操作還是錯的大哭
  3. 編譯自己的程序的時候出現錯誤:/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。
  • 終於對了,我都把那些選項背會了。 





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章