您尚未登录。

楼主 #1 2018-02-16 12:50:31

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

离线

楼主 #4 2018-02-16 20:30:36

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

落雁 说:

buildroot 里面开启 png,把生成的libpng.so* 拷贝到文件系统试一试。

落雁哥,文件系上加了libpng.so*也是不能显示,是不是交叉编译是没把png图片编译进去

离线

楼主 #5 2018-02-16 20:31:58

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:

参考网址: png-images-not-displayed-with-qt-and-visual-studio

以下是自动翻译:

在Qt支持的所有图像格式中,PNG支持是内置的,不需要任何外部插件加载。
另外,当我在预配置的开发机器上启动我的应用程序时,即使我需要任何特定的Qt插件,它也会自动加载。

我的理解:
Qt只要加载了 libpng.so*, 就可以内置支持png了。

晕哥,文件系上加了libpng.so*也是不能显示,是不是交叉编译是没把png图片编译进去?

离线

楼主 #8 2018-02-16 22:35:28

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:

如果上面的办法不能解决,
可以通过qrc 文件把 png等资源文件静态链接到可执行文件

参考: http://blog.csdn.net/liang19890820/article/details/51994441

晕哥,上面说的不是很明白,工程中没有.qrc 文件要怎么弄呢

离线

楼主 #10 2018-02-17 09:18:14

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:

新建.qrc文本文件,把内容填好,然后修改.pro工程文件,把.qrc加进去,重新qmake编译链接。


晕哥,好像不管用,还是不行

.pro工程文件
#-------------------------------------------------
#
# Project created by QtCreator 2018-02-15T22:18:11
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = tst
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0


SOURCES += \
        main.cpp \
        mainwindow.cpp

HEADERS += \
        mainwindow.h

FORMS += \
        mainwindow.ui
#引入icon.qrc文件
RESOURCES += \
    icon.qrc
RC_FILE=icon.rc





icon.qrc文件
<RCC>
    <qresource prefix="/new/prefix1">
        <file>03.ico</file>
        <file>error_info.png</file>
    </qresource>
</RCC>






MainWindow.cpp文件

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    qDebug()<<"Date:xxxxxxxxxxxxxx";
    ui->line_passwd->setEchoMode(QLineEdit::Password);
    ui->toolButton->setIcon(QIcon(":/new/prefix1/03.ico"));
    ui->toolButton_2->setIcon(QIcon(":/new/prefix1/error_info.png"));

    ui->toolButton->setIconSize(QSize(300,100));


}

win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片

离线

楼主 #11 2018-02-17 09:34:43

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥,只是用qmake编译,不知道怎样链接

离线

楼主 #13 2018-02-17 11:06:41

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

zhuacai 说:
晕哥 说:

新建.qrc文本文件,把内容填好,然后修改.pro工程文件,把.qrc加进去,重新qmake编译链接。




.pro工程文件
#-------------------------------------------------
#
# Project created by QtCreator 2018-02-15T22:18:11
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = tst
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0


SOURCES += \
        main.cpp \
        mainwindow.cpp

HEADERS += \
        mainwindow.h

FORMS += \
        mainwindow.ui
#引入icon.qrc文件
RESOURCES += \
    icon.qrc
RC_FILE=icon.rc





icon.qrc文件
<RCC>
    <qresource prefix="/new/prefix1">
        <file>03.ico</file>
        <file>error_info.png</file>
    </qresource>
</RCC>






MainWindow.cpp文件

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    qDebug()<<"Date:xxxxxxxxxxxxxx";
    ui->line_passwd->setEchoMode(QLineEdit::Password);
    ui->toolButton->setIcon(QIcon(":/new/prefix1/03.ico"));
    ui->toolButton_2->setIcon(QIcon(":/new/prefix1/error_info.png"));

    ui->toolButton->setIconSize(QSize(300,100));


}

晕哥,daydayup哥,现在win上写的qt程序可以显示ico,gif,png图片,交叉编译后在开发板上只能显示ico,不能gif,png,jpg显图片

离线

楼主 #15 2018-02-17 11:16:15

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:

我写了一个简单的demo, 你看下能否工作,专门测试png有没有起作用的:

#include <QImage>
#include <iostream>

using namespace std;

int main()
{
	QImage image("test.png");
	cout << image.width() << "," << image.height() << endl;
	return 0;
}

我这里输出:

quite@ubuntu:/disk2/qimage$ ./png_test
320,240


晕哥,这是什么用软件写的,能发程序我测下吗,图片是放到什么位置呢

离线

楼主 #18 2018-02-17 11:31:07

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:
zhuacai 说:

晕哥,这是什么用软件写的,能发程序我测下吗,图片是放到什么位置呢

和可执行文件放在一个目录即可.


晕哥,读不出来

#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    QImage inage(":/new/prefix1/error_info.png");
    qDebug()<<inage.width()<<","<<inage.height()<<endl;

    return a.exec();
}


# ./tst -platform linuxfb
Date:xxxxxxxxxxxxxx
0 , 0

离线

楼主 #19 2018-02-17 11:40:14

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

zhuacai 说:
晕哥 说:
zhuacai 说:

晕哥,这是什么用软件写的,能发程序我测下吗,图片是放到什么位置呢

和可执行文件放在一个目录即可.


晕哥,读不出来

#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    QImage inage(":/new/prefix1/error_info.png");
    qDebug()<<inage.width()<<","<<inage.height()<<endl;

    return a.exec();
}


# ./tst -platform linuxfb
Date:xxxxxxxxxxxxxx
0 , 0

#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    QImage inage(":/new/prefix1/error_info.png");
    qDebug()<<inage.width()<<","<<inage.height()<<endl;

    QImage inage2(":/new/prefix1/03.ico");
    qDebug()<<inage2.width()<<","<<inage2.height()<<endl;

    return a.exec();
}

晕哥,可以读出ioc,png读不出来

# ./tst -platform linuxfb
Date:xxxxxxxxxxxxxx
0 , 0

152 , 152

离线

楼主 #21 2018-02-17 14:26:45

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:

不用内嵌那种方式呢?


#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    QImage inage("error_info.png");
    qDebug()<<inage.width()<<","<<inage.height()<<endl;

    QImage inage2("03.ico");
    qDebug()<<inage2.width()<<","<<inage2.height()<<endl;

    return a.exec();
}



晕哥,也是一样只能读ico
# ./tst -platform linuxfb
Date:xxxxxxxxxxxxxx
0 , 0

152 , 152

^C# ^C
# rm 03.ico
# ./tst -platform linuxfb
Date:xxxxxxxxxxxxxx
0 , 0

0 , 0

离线

楼主 #23 2018-02-17 15:45:12

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

daydayup 说:

上面这个在电脑上正常吧?
感觉你的嵌入式系统的libpng库出问题了。

感谢daydayup的回答,对是嵌入式系统的libpng库出问题了
开始我以为是缺libpng库,就直接用buildroot编译libpng库拷到开发板上,也不行,原来QT是用的Q库,就是libpng.os
export QT_PLUGIN_PATH=/usr/lib/qt/plugins/下面的imageformats下面没有对应的libpng.so,libqgif.so,libqjpeg.so库,
然后在liunx交叉qt5.9.1后把/home/clark/QtEnv/QtEmbedded-5.9.1-arm/plugins/imageformats下面libpng.so,libqgif.so,libqjpeg.so库拷到开发板上的/usr/lib/qt/plugins/imageformats下面的就可以了

离线

楼主 #25 2018-02-17 17:24:52

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

daydayup 说:

哈,解决了就好,给后来到这里的朋友提供了一个解决思路。
我觉得把 libpng* 拷贝到/usr/lib 里面应该也是可以的。

daydayup哥,我上面说错了,现在发现没有libpng.so,只有libqicns.so  libqjpeg.so  libqtga.so   libqwbmp.so libqgif.so   libqico.so   libqsvg.so   libqtiff.so  libqwebp.so 所以还是不能显示png图片,只能显示gif,ico,jpg图片,网上查了一下说QT5内置支持png,但是不知道怎样才能显示png图片,还
请大神们帮忙

离线

楼主 #27 2018-02-17 18:05:19

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

daydayup 说:
zhuacai 说:
daydayup 说:

哈,解决了就好,给后来到这里的朋友提供了一个解决思路。
我觉得把 libpng* 拷贝到/usr/lib 里面应该也是可以的。

daydayup哥,我上面说错了,现在发现没有libpng.so,只有libqicns.so  libqjpeg.so  libqtga.so   libqwbmp.so libqgif.so   libqico.so   libqsvg.so   libqtiff.so  libqwebp.so 所以还是不能显示png图片,只能显示gif,ico,jpg图片,网上查了一下说QT5内置支持png,但是不知道怎样才能显示png图片,还
请大神们帮忙

内置支持png的意思是,不再需要比如qgif,qjpeg类似的插件,但是libpng.so*一定是需要的。
如果把libpng.so*拷贝到/usr/lib应该可以吧?

daydayup哥,libpng.so*拷贝/usr/lib下了还是不行

# find / -name libpng*
/usr/lib/libpng16.so.16.31.0
/usr/lib/qt/plugins/imageformats/libpng.so
/usr/lib/libpng.so
/usr/lib/libpng16.so
/usr/lib/libpng16.so.16

离线

楼主 #28 2018-02-17 18:42:10

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

Qt 5.9帮助文档看到的不是很明白说什么

Qt 5.9
Qt GUI
LibPNG

Qt 5.9.1 Reference Documentation

LibPNG
libpng is the official PNG reference library.
Used in the qpng image plugin. Configure with -system-png or -no-png to avoid.
The sources can be found in qtbase/src/3rdparty/libpng.
Project Homepage, upstream version: 1.6.28

  Copyright (c) 1998-2017 Glenn Randers-Pehrson
  Copyright (c) 2000-2017 Simon-Pierre Cadieux
  Copyright (c) 2000-2017 Eric S. Raymond
  Copyright (c) 2000-2017 Mans Rullgard
  Copyright (c) 2000-2017 Cosmin Truta
  Copyright (c) 2000-2017 Gilles Vollant
  Copyright (c) 2000-2017 James Yu
  Copyright (c) 2000-2017 Mandar Sahastrabuddhe
  Copyright (c) 1998-2000 Tom Lane
  Copyright (c) 1998-2000 Willem van Schaik
  Copyright (c) 1996-1997 Andreas Dilger
  Copyright (c) 1996-1997 John Bowler
  Copyright (c) 1996-1997 Kevin Bracey
  Copyright (c) 1996-1997 Sam Bushell
  Copyright (c) 1996-1997 Magnus Holmgren
  Copyright (c) 1996-1997 Greg Roelofs
  Copyright (c) 1996-1997 Tom Tanner
  Copyright (c) 1995-1996 Dave Martindale
  Copyright (c) 1995-1996 Paul Schmidt
  Copyright (c) 1995-1996 Tim Wegner
  Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.

libpng License.

  This copy of the libpng notices is provided for your convenience.  In case of
  any discrepancy between this copy and the notices in the file png.h that is
  included in the libpng distribution, the latter shall prevail.

  COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:

  If you modify libpng you may insert additional notices immediately following
  this sentence.

  This code is released under the libpng license.

  libpng versions 1.0.7, July 1, 2000 through 1.6.28, January 5, 2017 are
  Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
  derived from libpng-1.0.6, and are distributed according to the same
  disclaimer and license as libpng-1.0.6 with the following individuals
  added to the list of Contributing Authors:

     Simon-Pierre Cadieux
     Eric S. Raymond
     Mans Rullgard
     Cosmin Truta
     Gilles Vollant
     James Yu
     Mandar Sahastrabuddhe

  and with the following additions to the disclaimer:

     There is no warranty against interference with your enjoyment of the
     library or against infringement.  There is no warranty that our
     efforts or the library will fulfill any of your particular purposes
     or needs.  This library is provided with all faults, and the entire
     risk of satisfactory quality, performance, accuracy, and effort is with
     the user.

  Some files in the "contrib" directory and some configure-generated
  files that are distributed with libpng have other copyright owners and
  are released under other open source licenses.

  libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
  Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
  libpng-0.96, and are distributed according to the same disclaimer and
  license as libpng-0.96, with the following individuals added to the list
  of Contributing Authors:

     Tom Lane
     Glenn Randers-Pehrson
     Willem van Schaik

  libpng versions 0.89, June 1996, through 0.96, May 1997, are
  Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
  and are distributed according to the same disclaimer and license as
  libpng-0.88, with the following individuals added to the list of
  Contributing Authors:

     John Bowler
     Kevin Bracey
     Sam Bushell
     Magnus Holmgren
     Greg Roelofs
     Tom Tanner

  Some files in the "scripts" directory have other copyright owners
  but are released under this license.

  libpng versions 0.5, May 1995, through 0.88, January 1996, are
  Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.

  For the purposes of this copyright and license, "Contributing Authors"
  is defined as the following set of individuals:

     Andreas Dilger
     Dave Martindale
     Guy Eric Schalnat
     Paul Schmidt
     Tim Wegner

  The PNG Reference Library is supplied "AS IS".  The Contributing Authors
  and Group 42, Inc. disclaim all warranties, expressed or implied,
  including, without limitation, the warranties of merchantability and of
  fitness for any purpose.  The Contributing Authors and Group 42, Inc.
  assume no liability for direct, indirect, incidental, special, exemplary,
  or consequential damages, which may result from the use of the PNG
  Reference Library, even if advised of the possibility of such damage.

  Permission is hereby granted to use, copy, modify, and distribute this
  source code, or portions hereof, for any purpose, without fee, subject
  to the following restrictions:

    1. The origin of this source code must not be misrepresented.

    2. Altered versions must be plainly marked as such and must not
       be misrepresented as being the original source.

    3. This Copyright notice may not be removed or altered from any
       source or altered source distribution.

  The Contributing Authors and Group 42, Inc. specifically permit, without
  fee, and encourage the use of this source code as a component to
  supporting the PNG file format in commercial products.  If you use this
  source code in a product, acknowledgment is not required but would be
  appreciated.

  END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.

  TRADEMARK:

  The name "libpng" has not been registered by the Copyright owner
  as a trademark in any jurisdiction.  However, because libpng has
  been distributed and maintained world-wide, continually since 1995,
  the Copyright owner claims "common-law trademark protection" in any
  jurisdiction where common-law trademark is recognized.

  OSI CERTIFICATION:

  Libpng is OSI Certified Open Source Software.  OSI Certified Open Source is
  a certification mark of the Open Source Initiative. OSI has not addressed
  the additional disclaimers inserted at version 1.0.7.

  EXPORT CONTROL:

  The Copyright owner believes that the Export Control Classification
  Number (ECCN) for libpng is EAR99, which means not subject to export
  controls or International Traffic in Arms Regulations (ITAR) because
  it is open source, publicly available software, that does not contain
  any encryption software.  See the EAR, paragraphs 734.3(b)(3) and
  734.7(b).

  Glenn Randers-Pehrson
  glennrp at users.sourceforge.net
  January 5, 2017

离线

楼主 #30 2018-02-17 21:19:56

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

daydayup 说:

那现在问题解决了吗?
你去buildroot Qt配置那里看下是不是没勾png?


daydayup哥,Qt配置里的png己经勾了,现在还是不能显示png图片

离线

楼主 #33 2018-02-17 22:43:35

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:

http://zarb.org/~gc/html/libpng.html
你把这个demo在电脑上跑一下试一试,
然后再到板子上再试,
如果板子不行,
那么肯定是板子的libpng出问题了。

晕哥,上面demo怎样编译呢,编译时找不到png.h这个头文件呢

离线

楼主 #35 2018-02-18 23:08:18

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:
zhuacai 说:
daydayup 说:

那现在问题解决了吗?
你去buildroot Qt配置那里看下是不是没勾png?


daydayup哥,Qt配置里的png己经勾了,现在还是不能显示png图片

严重怀疑板上的libpng有问题,你弄个简单的png test demo试一试就知道libpng是否正确了。


晕哥,liunx上装了QtCreator然后然后编译在win上写的工程,在liunx上可以显示png图片

离线

楼主 #37 2018-02-19 10:53:20

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:

是用32楼的代码吗?


晕哥,不是,不知道怎样编译32楼的demo,我用gcc xxx.c -o xxx 编译提示找不到png.h头文件,用-I指定了png头文件,又出现很多错误,

离线

楼主 #38 2018-02-19 10:54:36

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

zhuacai 说:
晕哥 说:

是用32楼的代码吗?


晕哥,不是,不知道怎样编译32楼的demo,我用gcc xxx.c -o xxx 编译提示找不到png.h头文件,用-I指定了png头文件,又出现很多错误,所以liunx上装了QtCreator然后编译在win上写的工程,在liunx上可以显示png图片

离线

楼主 #40 2018-02-19 11:41:08

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

daydayup 说:
zhuacai 说:
zhuacai 说:

晕哥,不是,不知道怎样编译32楼的demo,我用gcc xxx.c -o xxx 编译提示找不到png.h头文件,用-I指定了png头文件,又出现很多错误,所以liunx上装了QtCreator然后编译在win上写的工程,在liunx上可以显示png图片

用34# 楼的方法试一试。


daydayup哥,安装apt-get install libpng-dev编译提示还找不到png.h头文件

离线

楼主 #42 2018-02-19 18:52:00

zhuacai
会员
注册时间: 2017-12-16
已发帖子: 234
积分: 233.5

Re: 各位大神新年好,win上写的qt程序可以显示png图片,交叉编译后在开发板上不能显图片,要怎么弄才能显示图片呢

晕哥 说:

不会啊,我的正常哦。

sudo apt-get install libpng-dev
sudo apt-get install libpng12-dev

$ find /usr/ |grep png.h
/usr/include/png.h
/usr/include/libpng12/png.h

编译运行演示代码:

$gcc -o test test.c -lpng

$ ./test
Usage: program_name <file_in> <file_out>


晕哥,在liunx纺译通过了输出以[process_file] color_type of input file must be PNG_COLOR_TYPE_RGBA (6) (is 3)

root@ubuntu:/home/vv3/qt5# ./tty tst/03.png 04.png
[process_file] color_type of input file must be PNG_COLOR_TYPE_RGBA (6) (is 3)
Aborted (core dumped)


用arm-linux-gnueabihf-gcc编译器交叉编译出错了,是什么问题呢
root@ubuntu:/home/vv3/qt5# arm-linux-gnueabihf-gcc -o tty tty.c -I/home/vv3/Downloads/buildroot-2017.08.1/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include -L/home/vv3/Downloads/buildroot-2017.08.1/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: cannot find /lib/libc.so.6
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: cannot find /usr/lib/libc_nonshared.a
/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8/../../../../arm-linux-gnueabihf/bin/ld: cannot find /lib/ld-linux-armhf.so.3
collect2: error: ld returned 1 exit status
root@ubuntu:/home/vv3/qt5#

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn