首页 > 代码库 > Fedora22编译Qt3.3.X

Fedora22编译Qt3.3.X

                      FC22编译QT3笔记

安装g++

dnf install gcc-c++

1,configure

./configure -thread -no-nis -system-libpng -system-libjpeg -system-libmng -system-zlib - nomake examples -- nomake tutorial

2,gmake

2.1 error: ‘ptrdiff_t‘ does not name a type

打开include\qvaluelist.h 加入#include <stddef.h>

 

2.2 forward declaration of ‘png_info {aka struct png_info_def}‘

这是png15之后的api升级了,参考

https://github.com/alekseysidorov/gentoo-stuff/blob/master/x11-libs/qt/files/qt-3.3.8-libpng15.patch

打开kernel\qpngio.cpp

在首行#include <png.h>后加入

#include <zlib.h>

 

setup_qt函数中png_get_IHDR函数后面加入

png_colorp info_ptr_palette = NULL;

int info_ptr_num_palette = 0;

if (png_get_valid(png_ptr, info_ptr, PNG_INFO_PLTE)) {

    png_get_PLTE(png_ptr, info_ptr, &info_ptr_palette, &info_ptr_num_palette);

}

 

png_bytep info_ptr_trans_alpha = NULL;

int info_ptr_num_trans = 0;

png_color_16p info_ptr_trans_color = NULL;

 

if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {

    png_get_tRNS(png_ptr, info_ptr, &info_ptr_trans_alpha, &info_ptr_num_trans, &info_ptr_trans_color);

}

 

if ( bit_depth == 1 && info_ptr->channels == 1 ) { 改为

if ( bit_depth == 1 && png_get_channels(png_ptr, info_ptr) == 1 ) {

 

163行

const int g = info_ptr->trans_values.gray; 改为

const int g = info_ptr_trans_color->gray;

 

187行

&& info_ptr->num_palette <= 256 ) 改为

&& info_ptr_num_palette <= 256 )

 

196行

if (!image.create(width, height, bit_depth, info_ptr->num_palette

改为

if (!image.create(width, height, bit_depth, info_ptr_num_palette

 

201行

            while ( i < info_ptr->num_trans ) {

                image.setColor(i, qRgba(

                    info_ptr->palette[i].red,

                    info_ptr->palette[i].green,

                    info_ptr->palette[i].blue,

                    info_ptr->trans[i]

                    )

                );

                i++;

            }

改为

            while ( i < info_ptr_num_trans ) {

                image.setColor(i, qRgba(

                    info_ptr_palette[i].red,

                    info_ptr_palette[i].green,

                    info_ptr_palette[i].blue,

                    info_ptr_trans_alpha[i]

                    )

                );

                i++;

            }

 

303行:

if (setjmp(png_ptr->jmpbuf)) { 改为

if (setjmp(png_jmpbuf(png_ptr))) {

 

488行:

if (setjmp(png_ptr->jmpbuf)) { 改为

if (setjmp(png_jmpbuf(png_ptr))) {

 

510行:

info_ptr->channels = 一段注释掉

 

527行:    //png_set_sBIT(png_ptr, info_ptr, 8);

    info_ptr->sig_bit.red = 8;

    info_ptr->sig_bit.green = 8;

    info_ptr->sig_bit.blue = 8;

注释掉,添加

 

    png_color_8 sig_bit;

    sig_bit.red = 8;

    sig_bit.green = 8;

    sig_bit.blue = 8;

    png_set_sBIT(png_ptr, info_ptr, &sig_bit);

 

551行:

            info_ptr->palette[i].red = qRed(rgb);

            info_ptr->palette[i].green = qGreen(rgb);

            info_ptr->palette[i].blue = qBlue(rgb);

改为

            info_ptr_palette[i].red = qRed(rgb);

            info_ptr_palette[i].green = qGreen(rgb);

            info_ptr_palette[i].blue = qBlue(rgb);

上面添加:

png_colorp info_ptr_palette = NULL;

int tmp;

png_get_PLTE(png_ptr, info_ptr, &info_ptr_palette, &tmp);

 

573行:

info_ptr->sig_bit.alpha = 8;

改为

        png_color_8p sig_bit;

        png_get_sBIT(png_ptr, info_ptr, &sig_bit);

        sig_bit->alpha = 8;

        png_set_sBIT(png_ptr, info_ptr, sig_bit);

 

1063行

if (setjmp(png_ptr->jmpbuf)) { 改为

if (setjmp(png_jmpbuf(png_ptr))) {

 

1090行

if (setjmp(png_ptr->jmpbuf)) { 改为

if (setjmp(png_jmpbuf(png_ptr))) {

 

1150行:

unused_data = http://www.mamicode.com/(int)png->buffer_size; // Since libpng doesn‘t tell us 改为

unused_data = http://www.mamicode.com/png_process_data_pause(png, 0);

 

 

2.3 qjpegio.cpp:59:21: fatal error: jpeglib.h: No such file or directory

yum install libjpeg-devel

 

2.4 qmngio.cpp:58:20: fatal error: libmng.h: No such file or directory

yum install libmng-devel

 

2.5 undefined reference to `qInitImages_designercore()‘

qInitImages_designercore() 原本因该在

tools/designer/designer/qmake_image_collection.cpp

文件中,打开一看,文件中没有这个函数

该文件不是qt自带的文件,是通过命令生成的:

/qt3/bin/uic  -embed designercore images/designer_adjustsize.png -o qmake_image_collection.cpp

运行该命令报错:

libpng error: bad parameters to zlib

uic: cannot load image file images/designer_adjustsize.png

归结原因是qt无法读取png图片.

最终定位原因,是qt自带的zlib和系统的版本不匹配!

configure中加入-system-zlib

顺利编译通过

 

2.6 qmake: command not found

 

3,设置环境变量

 

#export QT env

export QTDIR=/qt3

export PATH=$QTDIR/bin:$PATH

export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH

export DISPLAY=:0.0

#end export QT env

Fedora22编译Qt3.3.X