编译qt5.9-arm-qmake

本文详细介绍了在ARM环境下配置gcc编译器及使用Qt5.9进行交叉编译的过程,包括解决编译过程中遇到的错误,如链接器无法找到文件、Qt模块编译失败等常见问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、arm-gcc环境配置

    tar xvf rock3288-kernel-arm-linux-gcc -C /opt

    vim .basgrc 在最后面添加
    
    export PATH=/opt/gcc-linaro-arm-linux-gnueabihf-4.9/bin:$PATH
    
    用arm-linux-gnueabihf-g++ -v 会提示找不到文件或路径
    
    我用的是Ubuntu16.04 x64, 需要下载32位库,百度。
    
    配置成功后: arm-linux-gnueabihf-g++ -v 可以看到版本信息

二、qt5.9 arm-qmake 

    1、qt-everywhere-opensource-src-5.9.0/qtbase/mkspecs$ cp -r  linux-arm-gnueabi-g++/ linux-arm-gnueabihf-g++/
    
    2、修改linux-arm-gnueabihf-g++ qmake.conf 为
    
    #
    # qmake configuration for building with arm-linux-gnueabihf-g++
    #

    MAKEFILE_GENERATOR      = UNIX
    CONFIG                 += incremental
    QMAKE_INCREMENTAL_STYLE = sublib

    include(../common/linux.conf)
    include(../common/gcc-base-unix.conf)
    include(../common/g++-unix.conf)

    # modifications to g++.conf
    QMAKE_CC                = arm-linux-gnueabihf-gcc
    QMAKE_CXX               = arm-linux-gnueabihf-g++
    QMAKE_LINK              = arm-linux-gnueabihf-g++
    QMAKE_LINK_SHLIB        = arm-linux-gnueabihf-g++

    # modifications to linux.conf
    QMAKE_AR                = arm-linux-gnueabihf-ar cqs
    QMAKE_OBJCOPY           = arm-linux-gnueabihf-objcopy
    QMAKE_NM                = arm-linux-gnueabihf-nm -P
    QMAKE_STRIP             = arm-linux-gnueabihf-strip
    load(qt_config)
    
    3、 ./configure --prefix=/usr/local/qt5.9-arm-linux -opensource -release -shared -xplatform linux-arm-gnueabihf-g++ -no-opengl -nomake examples
    
    4、        make 时会有错误提醒
            1、
            .obj/qgeotiledmapscene.o:qgeotiledmapscene.cpp:function QGeoTiledMapRootNode::updateTiles(QGeoTiledMapTileContainerNode*, QGeoTiledMapScenePrivate*, double, QQuickWindow*, bool): error: undefined reference to 'QSGDefaultImageNode::setAnisotropyLevel(QSGTexture::AnisotropyLevel)'
            collect2: error: ld returned 1 exit status
            Makefile:671: recipe for target '../../lib/libQt5Location.so.5.9.0' failed
            make[3]: *** [../../lib/libQt5Location.so.5.9.0] Error 1
            make[3]: Leaving directory '/home/wgd/src/qt-everywhere-opensource-src-5.9.0/qtlocation/src/location'
            Makefile:152: recipe for target 'sub-location-make_first' failed
            make[2]: *** [sub-location-make_first] Error 2
            make[2]: Leaving directory '/home/wgd/src/qt-everywhere-opensource-src-5.9.0/qtlocation/src'
            Makefile:47: recipe for target 'sub-src-make_first' failed
            make[1]: *** [sub-src-make_first] Error 2
            make[1]: Leaving directory '/home/wgd/src/qt-everywhere-opensource-src-5.9.0/qtlocation'
            Makefile:891: recipe for target 'module-qtlocation-make_first' failed
            make: *** [module-qtlocation-make_first] Error 2
            解决屏蔽如下
            ~/src/qt-everywhere-opensource-src-5.9.0$ vim qtlocation/src/location/maps/qgeotiledmapscene.cpp 
            
            609 /*********
            610                 if (ogl)
            611                     static_cast<QSGDefaultImageNode *>(node)->setAnisotropyLevel(QSGTexture::Anisotropy16x);
            612 **********/
            613                 dirtyBits |= QSGNode::DirtyMaterial;
            614             }
            615             if (dirtyBits != 0)
            616                 node->markDirty(dirtyBits);
            617             it++;
            618         }
            619     }
            620 
            621     for (const QGeoTileSpec &s : toAdd) {
            622         QGeoTileTexture *tileTexture = d->m_textures.value(s).data();
            623         if (!tileTexture || tileTexture->image.isNull())
            624             continue;
            625         QSGImageNode *tileNode = window->createImageNode();
            626         // note: setTexture will update coordinates so do it here, before we buildGeometry
            627         tileNode->setTexture(textures.value(s));
            628         if (d->buildGeometry(s, tileNode, overzooming)
            629                 && qgeotiledmapscene_isTileInViewport(tileNode->rect(), root->matrix(), straight)) {
            630             if (tileNode->texture()->textureSize().width() > d->m_tileSize * pixelRatio) {
            631                 tileNode->setFiltering(QSGTexture::Linear); // with mipmapping QSGTexture::Nearest generates artifacts
            632                 tileNode->setMipmapFiltering(QSGTexture::Linear);
            633             } else {
            634                 tileNode->setFiltering((d->m_linearScaling || overzooming) ? QSGTexture::Linear : QSGTexture::Nearest);
            635             }
            636 /**********
            637             if (ogl)
            638                 static_cast<QSGDefaultImageNode *>(tileNode)->setAnisotropyLevel(QSGTexture::Anisotropy16x);
            639 **********/
            
            2、错误
            include/mbgl/gl/gl.hpp:30:23: fatal error: GL/gl.h: No such file or directory
            #include <GL/gl.h>
                               ^
            compilation terminated.
            Makefile:18337: recipe for target '.obj/attribute.o' failed
            make[5]: *** [.obj/attribute.o] Error 1
            
            解决            
            ~/src/qt-everywhere-opensource-src-5.9.0$ vim qtlocation/src/plugins/plugins.pro 
            TEMPLATE = subdirs
            qtHaveModule(positioning): SUBDIRS +=  position
            #qtHaveModule(location): SUBDIRS += geoservices
            
    5、make -j4
    
    6、sudo make install
                                            
    

    

详细配置。static

./configure -prefix /opt/qt-4.8.7-arm -release -opensource -confirm-license -static -fast -no-largefile -no-exceptions -no-accessibility -no-stl -no-qt3support -no-xmlpatterns -no-multimedia -no-audio-backend -no-phonon -no-phonon-backend -no-svg -no-webkit -no-javascript-jit -no-script -no-scripttools -no-declarative -no-declarative-debug -qt-zlib -qt-freetype -no-gif -no-libtiff -qt-libpng -no-libmng -qt-libjpeg -no-openssl -nomake tools -nomake examples -nomake demos -nomake docs -nomake translations -no-nis -no-cups -no-iconv -no-pch -no-dbus -embedded arm -platform qws/linux-x86-g++ -xplatform qws/linux-arm-gnueabihf-g++ -no-gtkstyle -no-nas-sound -no-opengl -no-openvg -no-sm -no-xshape -no-xvideo -no-xsync -no-xinerama -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-mitshm -no-fontconfig -no-xinput -no-xkb -no-glib -qt-gfx-linuxfb -no-mouse-tslib -qt-kbd-linuxinput -no-mmx -no-3dnow -no-sse -no-sse2 -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 -no-avx

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值