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配置文件,需要修改, 分别是:
在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 “ C M A K E I N S T A L L P R E F I X " " {CMAKE_INSTALL_PREFIX}" " CMAKEINSTALLPREFIX""{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 “ C M A K E I N S T A L L P R E F I X " " {CMAKE_INSTALL_PREFIX}" " CMAKEINSTALLPREFIX""{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编译问题
库链接出错:
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} L I B S ) s e t t a r g e t p r o p e r t i e s ( l i n p h o n e c P R O P E R T I E S L I N K F L A G S " {LIBS}) set_target_properties(linphonec PROPERTIES LINK_FLAGS " LIBS)settargetproperties(linphonecPROPERTIESLINKFLAGS"{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 L I B S ) s e t t a r g e t p r o p e r t i e s ( l i n p h o n e c s h P R O P E R T I E S L I N K F L A G S " {LIBS}) set_target_properties(linphonecsh PROPERTIES LINK_FLAGS " LIBS)settargetproperties(linphonecshPROPERTIESLINKFLAGS"{LINPHONE_LDFLAGS}")
set_target_properties(linphonecsh PROPERTIES LINKER_LANGUAGE CXX)
daemon/CmakeLists.txt按照相同方式修改;
以上是遇到的比较棘手的一些问题;源代码未做修改,主要是修改编译相关脚本;