arm-linux-gnueabihf-gcc 5.2编译qt4.8.5

1、解压

tar xzvf qt-everywhere-opensource-src-4.8.5.tar.gz

2、 修改 qmake.conf

mkspecs/qws/linux-arm-gnueabi-g++/qmake.conf 

#
# qmake configuration for building with arm-none-linux-gnueabi-g++
#

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

QMAKE_LIBS_EGL         += -lEGL
QMAKE_LIBS_OPENGL_ES2  += -lGLESv2 -lEGL -lGAL
QMAKE_LIBS_OPENVG      += -lOpenVG -lEGL -lGAL

IMX6_CFLAGS             = -march=armv7-a -mfpu=neon -DLINUX=1 -DEGL_API_FB=1
QMAKE_CFLAGS           += $$IMX6_CFLAGS
QMAKE_CXXFLAGS         += $$IMX6_CFLAGS

DISTRO_OPTS += hard-float


# modifications to g++.conf
QMAKE_CC                = /opt/arm-5.2/gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc  -lts
QMAKE_CXX               = /opt/arm-5.2/gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++  -lts
QMAKE_LINK              = /opt/arm-5.2/gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++  -lts
QMAKE_LINK_SHLIB        = /opt/arm-5.2/gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++  -lts

# modifications to linux.conf
QMAKE_AR                = /opt/arm-5.2/gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ar cqs
QMAKE_OBJCOPY           = /opt/arm-5.2/gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-objcopy
QMAKE_STRIP             = /opt/arm-5.2/gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-strip

load(qt_config)

3.配置编译项 configure

#!/bin/bash
./configure -prefix /usr/local/Trolltech/Qt-4.8.5 \
-opensource  \
-confirm-license  \
-device-option CROSS_COMPILE=/opt/arm-5.2/gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- \
-release -shared \
-embedded arm \
-xplatform qws/linux-arm-gnueabi-g++ \
-fast \
-optimized-qmake \
-no-pch \
-qt-libjpeg \
-qt-zlib \
-qt-libpng \
-qt-freetype \
-little-endian \
-host-little-endian \
-no-qt3support \
-no-libtiff \
-no-libmng \
-no-opengl \
-no-mmx \
-no-sse \
-no-sse2 \
-no-3dnow \
-no-openssl \
-no-webkit \
-no-qvfb \
-no-phonon \
-no-nis \
-no-cups \
-no-glib \
-qt-mouse-tslib \
-nomake tools \
-nomake docs \
-nomake examples \
-qt-sql-sqlite \
-plugin-sql-sqlite \
-rpath \
-v \
-I/home/lyp/workspace/qt/arm-tslib/include \
-L/home/lyp/workspace/qt/arm-tslib/lib

4.编译及安装

make

sudo make install

遇到问题

 -I../../include/QtCore -I../../include/QtNetwork -I../../include -I../../include/QtGui -I.rcc/release-shared-emb-arm -Iimage -I../3rdparty/libpng -I../3rdparty/zlib -I../3rdparty/zlib -I../3rdparty/freetype/builds/unix -I../3rdparty/freetype/src -I../3rdparty/freetype/include -I../3rdparty/harfbuzz/src -Idialogs -I.moc/release-shared-emb-arm -I.uic/release-shared-emb-arm -o .obj/release-shared-emb-arm/qprintdialog_unix.o dialogs/qprintdialog_unix.cpp
dialogs/qprintdialog_unix.cpp: In destructor 'virtual QPrintPropertiesDialog::~QPrintPropertiesDialog()':
dialogs/qprintdialog_unix.cpp:281:19: error: 'class Ui::QPrintPropertiesWidget' has no member named 'cupsPropertiesPage'
     delete widget.cupsPropertiesPage;
                   ^
dialogs/qprintdialog_unix.cpp: In member function 'void QPrintPropertiesDialog::applyPrinterProperties(QPrinter*)':
dialogs/qprintdialog_unix.cpp:287:12: error: 'class Ui::QPrintPropertiesWidget' has no member named 'pageSetup'
     widget.pageSetup->setPrinter(p);
            ^
dialogs/qprintdialog_unix.cpp: In member function 'void QPrintPropertiesDialog::setupPrinter() const':
dialogs/qprintdialog_unix.cpp:292:12: error: 'const class Ui::QPrintPropertiesWidget' has no member named 'pageSetup'
     widget.pageSetup->setupPrinter();
            ^
dialogs/qprintdialog_unix.cpp: In member function 'void QPrintPropertiesDialog::selectPrinter()':
dialogs/qprintdialog_unix.cpp:337:16: error: 'class Ui::QPrintPropertiesWidget' has no member named 'cupsPropertiesPage'
         widget.cupsPropertiesPage->setEnabled(false);
                ^
dialogs/qprintdialog_unix.cpp:338:16: error: 'class Ui::QPrintPropertiesWidget' has no member named 'pageSetup'
         widget.pageSetup->selectPrinter(0);
                ^
dialogs/qprintdialog_unix.cpp: In member function 'void QPrintPropertiesDialog::selectPdfPsPrinter(const QPrinter*)':
dialogs/qprintdialog_unix.cpp:345:12: error: 'class Ui::QPrintPropertiesWidget' has no member named 'pageSetup'
     widget.pageSetup->selectPdfPsPrinter(p);
            ^
dialogs/qprintdialog_unix.cpp:346:12: error: 'class Ui::QPrintPropertiesWidget' has no member named 'tabs'
     widget.tabs->setTabEnabled(1, false); // disable the advanced tab
            ^
dialogs/qprintdialog_unix.cpp: In member function 'void QPrintDialogPrivate::init()':
dialogs/qprintdialog_unix.cpp:389:13: error: 'class Ui::QPrintSettingsOutput' has no member named 'color'
     options.color->setIconSize(QSize(32, 32));
             ^
dialogs/qprintdialog_unix.cpp:390:13: error: 'class Ui::QPrintSettingsOutput' has no member named 'color'
     options.color->setIcon(QIcon(QLatin1String(":/trolltech/dialogs/qprintdialog/images/status-color.png")));
             ^
dialogs/qprintdialog_unix.cpp:391:13: error: 'class Ui::QPrintSettingsOutput' has no member named 'grayscale'
     options.grayscale->setIconSize(QSize(32, 32));
             ^
dialogs/qprintdialog_unix.cpp:392:13: error: 'class Ui::QPrintSettingsOutput' has no member named 'grayscale'
     options.grayscale->setIcon(QIcon(QLatin1String(":/trolltech/dialogs/qprintdialog/images/status-gray-scale.png")));
             ^
dialogs/qprintdialog_unix.cpp:421:30: error: 'class Ui::QPrintSettingsOutput' has no member named 'reverse'
     QObject::connect(options.reverse, SIGNAL(toggled(bool)),
                              ^
dialogs/qprintdialog_unix.cpp: In member function 'void QPrintDialogPrivate::applyPrinterProperties(QPrinter*)':
dialogs/qprintdialog_unix.cpp:430:17: error: 'class Ui::QPrintSettingsOutput' has no member named 'color'
         options.color->setChecked(true);
                 ^
dialogs/qprintdialog_unix.cpp:432:17: error: 'class Ui::QPrintSettingsOutput' has no member named 'grayscale'
         options.grayscale->setChecked(true);
                 ^
dialogs/qprintdialog_unix.cpp:436:17: error: 'class Ui::QPrintSettingsOutput' has no member named 'noDuplex'
         options.noDuplex->setChecked(true); break;
                 ^
dialogs/qprintdialog_unix.cpp:439:17: error: 'class Ui::QPrintSettingsOutput' has no member named 'duplexLong'
         options.duplexLong->setChecked(true); break;
                 ^
dialogs/qprintdialog_unix.cpp:441:17: error: 'class Ui::QPrintSettingsOutput' has no member named 'duplexShort'
         options.duplexShort->setChecked(true); break;
                 ^
dialogs/qprintdialog_unix.cpp:443:13: error: 'class Ui::QPrintSettingsOutput' has no member named 'copies'
     options.copies->setValue(p->copyCount());
             ^
dialogs/qprintdialog_unix.cpp:444:13: error: 'class Ui::QPrintSettingsOutput' has no member named 'collate'
     options.collate->setChecked(p->collateCopies());
             ^
dialogs/qprintdialog_unix.cpp:445:13: error: 'class Ui::QPrintSettingsOutput' has no member named 'reverse'
     options.reverse->setChecked(p->pageOrder() == QPrinter::LastPageFirst);
             ^
dialogs/qprintdialog_unix.cpp: In member function 'void QPrintDialogPrivate::setupPrinter()':
dialogs/qprintdialog_unix.cpp:490:17: error: 'class Ui::QPrintSettingsOutput' has no member named 'duplex'
     if (options.duplex->isEnabled()) {
                 ^
dialogs/qprintdialog_unix.cpp:491:21: error: 'class Ui::QPrintSettingsOutput' has no member named 'noDuplex'
         if (options.noDuplex->isChecked())
                     ^
 

在ubuntu20中遇到了该问题,换了 ubuntu14就可以了

ubuntu20上的解决方案

以上错误显然是环境问题造成。

根据错误提示:

dialogs/qprintdialog_unix.cpp:281:19: error: 'class Ui::QPrintPropertiesWidget' has no member named 'cupsPropertiesPage'

打开文件dialogs/qprintdialog_unix.cpp

搜索 cupsPropertiesPage

arm-linux-gnueabihf-gcc 5.2编译qt4.8.5_第1张图片

 arm-linux-gnueabihf-gcc 5.2编译qt4.8.5_第2张图片

 找到这两个地方有调用到

可以看到跟QT_NO_CUPS 有关

配置选项带有-no-cups

arm-linux-gnueabihf-gcc 5.2编译qt4.8.5_第3张图片

 从代码中可以分析倒不是这句引起的,需要往上找widget的类型arm-linux-gnueabihf-gcc 5.2编译qt4.8.5_第4张图片

 arm-linux-gnueabihf-gcc 5.2编译qt4.8.5_第5张图片

 ui文件中有包含cupsPropertiesPage成员,为啥会提示没有?难道没有编译ui文件?难道跟make工具有关?换了下make3.8.1的后问题依然存在。

那是什么原因导致ui文件没成功被编译的?

‘Ubuntu20 交叉编译 Qt4.8 报错处理__圣_的博客-CSDN博客_ubuntu交叉编译qt

QT设计器设计的窗口部件,通过 uic 工具转换成C++代码。

用qt5.12.10带的uic替换后出现新的错误

arm-linux-gnueabihf-gcc 5.2编译qt4.8.5_第6张图片

 使用旧版gcc

1、安装gcc7并切换版本,使用update-alternatives进行版本切换,输入以下命令:

sudo apt-get install gcc-7 g++-7
# update-alternatives: --install 需要 <链接> <名称> <路径> <优先级>
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 100
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 50

查看gcc的默认版本,可以看到当前默认gcc版本为7,即切换成功。

sudo update-alternatives --config gcc

arm-linux-gnueabihf-gcc 5.2编译qt4.8.5_第7张图片

 查看当前gcc命令的软链接

ls -liat /usr/bin/gcc 
ls -liat /usr/bin/g++

重新配置和编译qt

问题2

lib/libQtGui.so: undefined reference to `ts_read_raw'

/lib/libQtGui.so: undefined reference to `ts_open'

/lib/libQtGui.so: undefined reference to `ts_fd'

/lib/libQtGui.so: undefined reference to `ts_config'

/lib/libQtGui.so: undefined reference to `ts_close'

/lib/libQtGui.so: undefined reference to `ts_read

解决办法:

/qmake.conf 文件(添加lts参数):

QMAKE_CC                = arm-linux-gcc -lts

QMAKE_CXX               = arm-linux-g++ -lts

QMAKE_LINK              = arm-linux-g++ -lts

QMAKE_LINK_SHLIB        = arm-linux-g++ -lts

arm编译QT4.8.5时出现lib/libQtGui.so: undefined reference to `ts_read_raw'的解决办法_navy电子爱好者的博客-CSDN博客

你可能感兴趣的:(Qt,arm,linux)