linphone arm交叉編譯過程記錄

Linphone交叉編譯過程:
在centos7上交叉編譯海思版本linphone (origin/release/4.2)使用過程:

經常需要執行命令:
find . -name “*.sh”|sudo xargs chmod +x

配置命令:
./configure --host=arm-linux --prefix=/home/app_comm/arm-compile/armlib/ CC=/opt/hisi-linux/x86-arm/arm-himix200-linux/bin/arm-himix200-linux-gcc

編譯使用命令:
./prepare.py desktop-raspberry -DENABLE_OPENH264=ON -DENABLE_WEBRTC_AEC=OFF -DENABLE_UNIT_TESTS=OFF -DENABLE_MKV=OFF -DENABLE_FFMPEG=ON -DENABLE_CXX_WRAPPER=OFF -DENABLE_NON_FREE_CODECS=ON -DENABLE_VCARD=OFF -DENABLE_BV16=OFF -DENABLE_V4L=OFF

使用linphone提供的樹莓派版本編譯的方式,但是樹莓派arm版本和海思arm版本不太一致,所以部分cmake配置需要手動修改

Arm版本信息:
執行(arm-himix200-linux-gcc –help可以獲取一些關於工具相關環境信息)
arm-himix200-linux-gcc -print-sysroot
獲取: /opt/hisi-linux/x86-arm/arm-himix200-linux/host_bin/…/target

添加環境變量:
export RASPBIAN_ROOTFS=/opt/hisi-linux/x86-arm/arm-himix200-linux/host_bin/…/target

編譯過程依賴2個cmake配置文件,需要修改, 分別是:

  1. linphone-desktop\linphone-sdk\cmake-builder\toolchains\toolchain-raspberry.cmake
  2. linphone-desktop\linphone-sdk\cmake-builder\configs\config-desktop-raspberry.cmake

在2文件中添加
set(CMAKE_SYSTEM_PROCESSOR “armv7”)

修改2文件關於ffmpeg的配置:
lcb_builder_cross_compilation_options(ffmpeg
“–prefix=${CMAKE_INSTALL_PREFIX}”
“–enable-cross-compile”

  •   "--cross-prefix=arm-linux-gnueabihf-"
    
  •   "--cross-prefix=arm-himix200-linux-"
      "--arch=arm"
      "--target-os=linux"
    

)

修改1文件 註釋掉關於環境的判斷,添加自己交叉編譯gcc路徑:
-if("$ENV{RASPBERRY_VERSION}" STREQUAL “”)
set(RASPBERRY_VERSION 1)
-else()

  •   if($ENV{RASPBERRY_VERSION} VERSION_GREATER 3)
    
  •           set(RASPBERRY_VERSION 3)
    
  •   else()
    
  •           set(RASPBERRY_VERSION $ENV{RASPBERRY_VERSION})
    
  •   endif()
    

-endif()

-if("$ENV{RASPBIAN_ROOTFS}" STREQUAL “”)

  •   message(FATAL_ERROR "Define the RASPBIAN_ROOTFS environment variable to point to the raspbian rootfs.")
    

-else()

  •   set(SYSROOT_PATH "$ENV{RASPBIAN_ROOTFS}")
    

-endif()
-set(TOOLCHAIN_HOST “arm-linux-gnueabihf”)
+#if(“KaTeX parse error: Expected 'EOF', got '#' at position 37: … STREQUAL "") +#̲ message(F…ENV{RASPBIAN_ROOTFS}”)
+#endif()
+#set(TOOLCHAIN_HOST “arm-linux-gnueabihf”)
+set(TOOLCHAIN_HOST “arm-himix200-linux”)

修改1文件, 因爲arm版本不一樣,需要查詢自己編譯的arm版本的c,c++flag的參數配上,添加-std=c++11 ,在編譯btctoolbox一直報錯,分析後發現是c++11標準參數沒有添加上,添加後解決
-if(RASPBERRY_VERSION VERSION_GREATER 2)

  •   set(CMAKE_C_FLAGS "-mcpu=cortex-a53 -mfpu=vfp -mfloat-abi=hard" CACHE STRING "Flags for Raspberry PI 3")
    
  •   set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "Flags for Raspberry PI 3")
    

-elseif(RASPBERRY_VERSION VERSION_GREATER 1)

  •   set(CMAKE_C_FLAGS "-mcpu=cortex-a7 -mfpu=vfp -mfloat-abi=hard" CACHE STRING "Flags for Raspberry PI 2")
    
  •   set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "Flags for Raspberry PI 2")
    

-else()

  •   set(CMAKE_C_FLAGS "-mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard" CACHE STRING "Flags for Raspberry PI 1 B+")
    
  •   set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "Flags for Raspberry PI 1 B+")
    

-endif()

-set(CMAKE_FIND_ROOT_PATH “CMAKEINSTALLPREFIX""{CMAKE_INSTALL_PREFIX}" "{CMAKE_SYSROOT}”)

  • set(CMAKE_C_FLAGS “-mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=softfp” CACHE STRING “Flags for Raspberry PI 1 B+”)
    +set(CMAKE_CXX_FLAGS “KaTeX parse error: Double subscript at position 9: {CMAKE_C_̲FLAGS}" CACHE S…{CMAKE_CXX_FLAGS} -std=c++11”)

  • set(CMAKE_FIND_ROOT_PATH “CMAKEINSTALLPREFIX""{CMAKE_INSTALL_PREFIX}" "{CMAKE_SYSROOT}”)

Ms2編譯問題:
修改 ms2 CmakeLists.txt
cmake_dependent_option(ENABLE_V4L “Enable Video4Linux support.” YES “ENABLE_VIDEO;LINUX_OR_BSD” NO)

改爲:
cmake_dependent_option(ENABLE_V4L “Enable Video4Linux support.” NO “ENABLE_VIDEO;LINUX_OR_BSD” NO)

添加:
set(ENABLE_X11_DEFAULT_VALUE NO)
set(ENABLE_GLX_DEFAULT_VALUE NO)

下載alsa源碼編譯成arm版本使用:
地址:https://www.alsa-project.org/main/index.php/Main_Page
Tar –xvf .

./configure --host=arm-linux --prefix=/home/app_comm/arm-compile/armlib/ CC=/opt/hisi-linux/x86-arm/arm-himix200-linux/bin/arm-himix200-linux-gcc

Make

配置linphone-desktop/linphone-sdk/mediastreamer2/cmake/FindALSA.cmake; 因爲ALSA是自定義的安裝路徑,導致find_package無法找到;在FindALSA.cmake文件中添加:
set(ALSA_INCLUDE_DIRS “/home/app_comm/arm-compile/armlib/include”)
set(ALSA_LIBRARIES “/home/app_comm/arm-compile/armlib/lib/libasound.so”)
解決這個問題;

Linphone編譯問題

  1. Ms2/cmake/FindFFmpeg.cmake添加
    set(HAVE_FUN_avcodec_get_context_defaults3 1)
    set(HAVE_FUN_avcodec_open2 1)

庫鏈接出錯:
arm-linux-gnueabi/bin/ld: warning: libbellesip.so.0, needed by …/src/ liblinphone.so.9, not found (try using -rpath or -rpath-link)

linphone編譯時會出現動態庫生成可以成功,但是console和daemon文件夾下的demo程序出現鏈接報錯的問題;經過分析應該是arm庫在x86環境下無法自動關聯自己依賴的庫,需要修改 console/CmakeLists.txt 和daemon/CmakeLists.txt文件,幫他鏈接關聯進去,具體修改:
添加:
set(LIBS
${BELLESIP_LIBRARIES}
${MEDIASTREAMER2_LIBRARIES}
${ORTP_LIBRARIES}
${BCTOOLBOX_CORE_LIBRARIES}
${XML2_LIBRARIES}
${BELR_LIBRARIES}
${LIBXSD_LIBRARIES}
)
if(WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL “WindowsStore”)
list(APPEND LIBS “Ws2_32”)
endif()
if(LIME_FOUND)
list(APPEND LIBS ${LIME_LIBRARIES})
endif()
if(ENABLE_LIME)
list(APPEND LIBS ${BZRTP_LIBRARIES})
endif()
if(ZLIB_FOUND)
list(APPEND LIBS ${ZLIB_LIBRARIES})
endif()
if(SOCI_FOUND)
list(APPEND LIBS ${SOCI_LIBRARIES})
endif()
if(SQLITE3_FOUND)
list(APPEND LIBS ${SQLITE3_LIBRARIES})
endif()
if(ICONV_FOUND)
list(APPEND LIBS ${ICONV_LIBRARIES})
endif()
if(ENABLE_TUNNEL)
list(APPEND LIBS ${TUNNEL_LIBRARIES})
endif()
if(MSVC AND NOT CMAKE_SYSTEM_NAME STREQUAL “WindowsPhone” AND NOT CMAKE_SYSTEM_NAME STREQUAL “WindowsStore”)
list(APPEND LIBS ${LIBGCC} ${LIBMINGWEX})
endif()
if(WIN32 AND NOT CMAKE_SYSTEM_NAME STREQUAL “WindowsPhone” AND NOT CMAKE_SYSTEM_NAME STREQUAL “WindowsStore”)
list(APPEND LIBS shlwapi)
endif()
if(INTL_FOUND)
list(APPEND LIBS ${INTL_LIBRARIES})
endif()
if(BELCARD_FOUND)
list(APPEND LIBS ${BELCARD_LIBRARIES})
endif()

link_directories("/home/app_comm/linphone/linphone-desktop/OUTPUT/desktop-raspberry/lib")
list(APPEND LIBS mbedtls mbedx509 mbedcrypto swscale vpx bzrtp srtp2 gsm opus speex speexdsp avcodec avutil swresample bcg729 asound stdc++)

修改:
add_executable(linphonec ${LINPHONEC_SOURCE_FILES})
-target_link_libraries(linphonec ${LINPHONE_LIBS_FOR_TOOLS} ${BCTOOLBOX_CORE_LIBRARIES} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES} ${XSD_LIBRARIES})
+target_link_libraries(linphonec ${LINPHONE_LIBS_FOR_TOOLS} LIBS)settargetproperties(linphonecPROPERTIESLINKFLAGS"{LIBS}) set_target_properties(linphonec PROPERTIES LINK_FLAGS "{LINPHONE_LDFLAGS}")
set_target_properties(linphonec PROPERTIES LINKER_LANGUAGE CXX)

@@ -54,7 +104,10 @@ if(WIN32)
endif()

add_executable(linphonecsh ${LINPHONECSH_SOURCE_FILES})
-target_link_libraries(linphonecsh ${LINPHONE_LIBS_FOR_TOOLS} ${BCTOOLBOX_CORE_LIBRARIES} ${ORTP_LIBRARIES})
+#target_include_directories(linphonecsh PUBLIC ${LINPHONE_INCLUDE_DIRS})
+#target_link_libraries(linphonecsh ${LINPHONE_LIBS_FOR_TOOLS} ${BCTOOLBOX_CORE_LIBRARIES} ${ORTP_LIBRARIES} mbedtls mbedx509 mbedcrypto)
+target_link_libraries(linphonecsh ${LINPHONE_LIBS_FOR_TOOLS})
+target_link_libraries(linphonecsh LIBS)settargetproperties(linphonecshPROPERTIESLINKFLAGS"{LIBS}) set_target_properties(linphonecsh PROPERTIES LINK_FLAGS "{LINPHONE_LDFLAGS}")
set_target_properties(linphonecsh PROPERTIES LINKER_LANGUAGE CXX)

daemon/CmakeLists.txt按照相同方式修改;

以上是遇到的比較棘手的一些問題;源代碼未做修改,主要是修改編譯相關腳本;

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