交叉编译的脚本:
# this is required
SET(CMAKE_SYSTEM_NAME Linux)
# specify the cross compiler
SET(CMAKE_C_COMPILER /home/hs/mentor/bin/arm-none-linux-gnueabi-gcc)
SET(CMAKE_CXX_COMPILER /home/hs/mentor/bin/arm-none-linux-gnueabi-g++)
# set build flag
SET(GNU_FLAGS "-march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 -fPIC -Wall")
SET(CMAKE_CXX_FLAGS "${GNU_FLAGS}")
SET(CMAKE_C_FLAGS "${GNU_FLAGS}")
#
IF( NOT CMAKE_BUILD_TYPE )
SET( CMAKE_BUILD_TYPE Release ... FORCE )
ENDIF()
#SET(CMAKE_INSTALL_PREFIX /home/test/testTaglib/taglib-1.10/cross_build)
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /home/hs/mentor)
# search for programs in the build host directories (not necessary)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# configure Boost and Qt
#SET(QT_QMAKE_EXECUTABLE /opt/qt-embedded/qmake)
#SET(BOOST_ROOT /opt/boost_arm)
SET(CMAKE_SYSTEM_NAME Linux)
# specify the cross compiler
SET(CMAKE_C_COMPILER /home/hs/mentor/bin/arm-none-linux-gnueabi-gcc)
SET(CMAKE_CXX_COMPILER /home/hs/mentor/bin/arm-none-linux-gnueabi-g++)
# set build flag
SET(GNU_FLAGS "-march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 -fPIC -Wall")
SET(CMAKE_CXX_FLAGS "${GNU_FLAGS}")
SET(CMAKE_C_FLAGS "${GNU_FLAGS}")
#
IF( NOT CMAKE_BUILD_TYPE )
SET( CMAKE_BUILD_TYPE Release ... FORCE )
ENDIF()
#SET(CMAKE_INSTALL_PREFIX /home/test/testTaglib/taglib-1.10/cross_build)
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /home/hs/mentor)
# search for programs in the build host directories (not necessary)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# configure Boost and Qt
#SET(QT_QMAKE_EXECUTABLE /opt/qt-embedded/qmake)
#SET(BOOST_ROOT /opt/boost_arm)
-----------------------------------
编译步骤:
mkdir cross_build
cmake -DCMAKE_INSTALL_PREFIX=/home/hs/taglib/cross_build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./toolChain.cmake
make
make install
---------------------------------------
解决运行时链接不到so文件的问题:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/app/xx/lib:
---------------------------------------
参考链接:
http://www.linuxfromscratch.org/blfs/view/svn/multimedia/taglib.html
https://taglib.github.io/
http://www.xuebuyuan.com/2005238.html
http://www.tuicool.com/articles/yAFnQ3