转载:http://blog.sina.com.cn/s/blog_6182b82201015ym1.html
编译qtopia最好使用的是低版本的gcc和g++. 举个简单的例子在qtopia的源代码中有个函数的使用
在qmemoryfile_unix.cpp中int open(const char*, int, ...),这个函数的使用就有问题了。因为open函数需要三个参数,而这里只有两个,新版本的gcc必须要求传入三个参数。所以这个会有错误。需要修个源码。。
还有在另外的一个文件中使用strrchr函数时,函数的第一个参数是const型的,新版本g++不支持报错了。而g++4.1编译则没有问题。所以这里我重新安装了g++4.1版本。
编译qtopia时候可能还会遇到问题
make[1]: Entering directory `/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/src'
echo '#include "kernel/qt.h"' >allmoc.cpp
g++ -c -I/usr/X11R6/include -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/include -I/usr/X11R6/include -pipe -O2 -Wall -W -DNO_DEBUG -fPIC -DQT_BUILTIN_GIF_READER=0 -DQT_NO_IMAGEIO_JPEG -DQT_NO_IMAGEIO_MNG -DQT_NO_SM_SUPPORT -DQT_NO_XKB -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/src/3rdparty/zlib -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/src/3rdparty/libpng -I3rdparty/kernel -I3rdparty/tools -o tmp/release-shared-linux-g++/tools/qmemoryfile_unix.o tools/qmemoryfile_unix.cpp
tools/qmemoryfile_unix.cpp: In member function ‘QMemoryFileData* QMemoryFile::openData(const QString&, int, uint)’:
tools/qmemoryfile_unix.cpp:149: warning: format not a string literal and no format arguments
tools/qmemoryfile_unix.cpp:152: warning: format not a string literal and no format arguments
tools/qmemoryfile_unix.cpp:181: warning: format not a string literal and no format arguments
tools/qmemoryfile_unix.cpp:190: warning: format not a string literal and no format arguments
tools/qmemoryfile_unix.cpp:235: warning: format not a string literal and no format arguments
In file included from /usr/include/fcntl.h:217,
from tools/qmemoryfile_unix.cpp:50:
In function ‘int open(const char*, int, ...)’,
inlined from ‘QMemoryFileData* QMemoryFile::openData(const QString&, int, uint)’ at tools/qmemoryfile_unix.cpp:143:
/usr/include/bits/fcntl2.h:51: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT in second argument needs 3 arguments
make[1]: *** [tmp/release-shared-linux-g++/tools/qmemoryfile_unix.o] Error 1
make[1]: Leaving directory `/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/src'
解决办法:
在Ubuntu 9.10上, gcc会严格检查open()的参数传递,如果第二个参数为O_CREAT的话(就像qtopia-2.2.0-FriendlyARM/qt2/src /tools/qmemoryfile_unix.cpp的143行这样),必须传入第三个参数mode。因此,手动修改x86-qtopia- 2.2.0/qt2/src/tools/qmemoryfile_unix.cpp 143行
将
if (!f)
f = ::open(tmpFile.latin1(), O_CREAT | O_WRONLY);
修改为
if (!f)
f = ::open(tmpFile.latin1(), O_CREAT | O_WRONLY, 0666);
make[1]: Entering directory `/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/src'
g++ -c -I/usr/X11R6/include -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/include -I/usr/X11R6/include -pipe -O2 -Wall -W -DNO_DEBUG -fPIC -DQT_BUILTIN_GIF_READER=0 -DQT_NO_IMAGEIO_JPEG -DQT_NO_IMAGEIO_MNG -DQT_NO_SM_SUPPORT -DQT_NO_XKB -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/src/3rdparty/zlib -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/src/3rdparty/libpng -I3rdparty/kernel -I3rdparty/tools -o tmp/release-shared-linux-g++/3rdparty/kernel/qmotifdnd_x11.o 3rdparty/kernel/qmotifdnd_x11.cpp
3rdparty/kernel/qmotifdnd_x11.cpp:80:22: error: X11/Xlib.h: No such file or directory
............
3rdparty/kernel/qmotifdnd_x11.cpp:902: error: ‘struct DndData’ has no member named ‘time’
make[1]: *** [tmp/release-shared-linux-g++/3rdparty/kernel/qmotifdnd_x11.o] Error 1
make[1]: Leaving directory `/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/src'
解决方法:
缺少x11/xlib.h,安装libx11-dev即可解决:
# sudo apt-get install libx11-dev
make[1]: Entering directory `/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/src'
g++ -c -I/usr/X11R6/include -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/include -I/usr/X11R6/include -pipe -O2 -Wall -W -DNO_DEBUG -fPIC -DQT_BUILTIN_GIF_READER=0 -DQT_NO_IMAGEIO_JPEG -DQT_NO_IMAGEIO_MNG -DQT_NO_SM_SUPPORT -DQT_NO_XKB -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/src/3rdparty/zlib -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/src/3rdparty/libpng -I3rdparty/kernel -I3rdparty/tools -o tmp/release-shared-linux-g++/kernel/qpsprinter.o kernel/qpsprinter.cpp
In file included from kernel/qpsprinter.cpp:97:
kernel/qt_x11.h:83:34: error: X11/extensions/shape.h: No such file or directory
In file included from kernel/qpsprinter.cpp:75:
kernel/qimage.h: In member function ‘int QImageTextKeyLang::operator<(const QImageTextKeyLang&) const’:
kernel/qimage.h:58: warning: suggest parentheses around ‘&&’ within ‘||’
make[1]: *** [tmp/release-shared-linux-g++/kernel/qpsprinter.o] Error 1
make[1]: Leaving directory `/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/src'
解决方法:
缺少X11/extensions/shape.h,安装x11proto-xext-dev即可解决:
# sudo apt-get install x11proto-xext-dev
make[1]: Entering directory `/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/tools/designer/uic'
g++ -L/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/lib -Wl,-rpath,/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/lib -o /opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/bin/uic uic.o ../shared/widgetdatabase.o ../shared/domtool.o ../integration/kdevelop/kdewidgets.o -lqt
/usr/bin/ld: cannot find -lqt
collect2: ld returned 1 exit status
make[1]: *** [/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/bin/uic] Error 1
make[1]: Leaving directory `/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/tools/designer/uic'
解决方法:
缺少lqt,安装libqt3-mt-dev即可解决:
# sudo apt-get install libqt3-mt-dev
carterlam 发表于 2010-3-1 17:21
接上:
***********************************
********* Build Qtopia ************
***********************************
make[5]: Entering directory `/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/src/libraries/qtopia'
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -Os -fPIC -DQTOPIA_DATA_LINKING -DQCONFIG="qconfig-qpe.h" -DQTOPIA_TARGET="qpe" -DQTOPIA_TRTARGET="libqpe" -DQT_NO_DEBUG -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/mkspecs/qws/linux-generic-g++ -I. -I../../../include/qtopia/private -I../../../pics/qpe -I../../../include -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/include -I../../../include/qtopia/private/ -I.moc/release-shared/ -o .obj/release-shared/qmemoryfile_unix.o qmemoryfile_unix.cpp
qmemoryfile_unix.cpp: In member function ‘QMemoryFileData* QMemoryFile::openData(const QString&, int, uint)’:
qmemoryfile_unix.cpp:149: warning: format not a string literal and no format arguments
qmemoryfile_unix.cpp:187: warning: format not a string literal and no format arguments
qmemoryfile_unix.cpp:232: warning: format not a string literal and no format arguments
In file included from /usr/include/fcntl.h:217,
from qmemoryfile_unix.cpp:48:
In function ‘int open(const char*, int, ...)’,
inlined from ‘QMemoryFileData* QMemoryFile::openData(const QString&, int, uint)’ at qmemoryfile_unix.cpp:141:
/usr/include/bits/fcntl2.h:51: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT in second argument needs 3 arguments
make[5]: *** [.obj/release-shared/qmemoryfile_unix.o] Error 1
make[5]: Leaving directory `/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/src/libraries/qtopia'
解决办法:
手动修改x86-qtopia-2.2.0/qtopia/src/libraries/qtopia/qmemoryfile_unix.cpp 141行
将
if (!f)
f = ::open(tmpFile.latin1(), O_CREAT | O_WRONLY);
修改为
if (!f)
f = ::open(tmpFile.latin1(), O_CREAT | O_WRONLY, 0666);
make[5]: Entering directory `/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/src/libraries/qtopia'
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -Os -fPIC -DQTOPIA_DATA_LINKING -DQCONFIG="qconfig-qpe.h" -DQTOPIA_TARGET="qpe" -DQTOPIA_TRTARGET="libqpe" -DQT_NO_DEBUG -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/mkspecs/qws/linux-generic-g++ -I. -I../../../include/qtopia/private -I../../../pics/qpe -I../../../include -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/include -I../../../include/qtopia/private/ -I.moc/release-shared/ -o .obj/release-shared/vobject.o backend/vobject.cpp
backend/vobject.cpp: In function ‘VObject* addGroup(VObject*, const char*)’:
backend/vobject.cpp:419: error: invalid conversion from ‘const char*’ to ‘char*’
backend/vobject.cpp: In function ‘void writeEncString(OFile*, const char*, bool)’:
backend/vobject.cpp:1111: warning: suggest parentheses around ‘&&’ within ‘||’
backend/vobject.cpp: In function ‘bool includesUnprintable(VObject*, bool)’:
backend/vobject.cpp:1168: warning: suggest parentheses around ‘&&’ within ‘||’
backend/vobject.cpp:1169: warning: suggest parentheses around ‘&&’ within ‘||’
make[5]: *** [.obj/release-shared/vobject.o] Error 1
make[5]: Leaving directory `/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/src/libraries/qtopia'
解决方法:
修改/x86-qtopia-2.2.0/qtopia/src/libraries/qtopia/backend/vobject.cpp:419行
char *dot = strrchr(g,'.');
为
char *dot = (char*)strrchr(g,'.');
make[5]: Entering directory `/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/src/libraries/qtopia'
test -d ../../../lib/ || mkdir -p ../../../lib/
rm -f libqpe.so.1.5.3 libqpe.so libqpe.so.1 libqpe.so.1.5
g++ -shared -Wl,-soname,libqpe.so.1 -o libqpe.so.1.5.3 .obj/release-shared/qmemoryfile.o .obj/release-shared/calendar.o .obj/release-shared/global.o .obj/release-shared/localtr.o .obj/release-shared/mimetype.o .obj/release-shared/menubutton.o .obj/release-shared/filemanager.o .obj/release-shared/fileselector.o .obj/release-shared/resource.o .obj/release-shared/qpeapplication.o .obj/release-shared/qpestyle.o .obj/release-shared/qpedialog.o .obj/release-shared/config.o .obj/release-shared/applnk.o .obj/release-shared/sound.o .obj/release-shared/tzselect.o .obj/release-shared/qmath.o .obj/release-shared/alarmserver.o .obj/release-shared/password.o .obj/release-shared/timestring.o .obj/release-shared/storage.o .obj/release-shared/qpemessagebox.o .obj/release-shared/qpedebug.o .obj/release-shared/qpemenubar.o .obj/release-shared/qpetoolbar.o .obj/release-shared/categorymenu.o .obj/release-shared/categoryedit_p.o .obj/release-shared/categoryselect.o .obj/release-shared/categorywidget.o .obj/release-shared/mediarecorderplugininterface.o .obj/release-shared/mediaplayerplugininterface.o .obj/release-shared/qdawg.o .obj/release-shared/datebookdb.o .obj/release-shared/xmlreader.o .obj/release-shared/imageedit.o .obj/release-shared/datebookmonth.o .obj/release-shared/qmemoryfile_unix.o .obj/release-shared/custom-qtopia.o .obj/release-shared/fontmanager.o .obj/release-shared/fontdatabase.o .obj/release-shared/qpedecoration_qws.o .obj/release-shared/network.o .obj/release-shared/networkinterface.o .obj/release-shared/qcopenvelope_qws.o .obj/release-shared/power.o .obj/release-shared/ir.o .obj/release-shared/pluginloader_p.o .obj/release-shared/bgexport.o .obj/release-shared/quuid.o .obj/release-shared/qlibrary.o .obj/release-shared/process.o .obj/release-shared/process_unix.o .obj/release-shared/qlibrary_unix.o .obj/release-shared/categories.o .obj/release-shared/stringutil.o .obj/release-shared/vcc_yacc.o .obj/release-shared/vobject.o .obj/release-shared/cp1252textcodec.o .obj/release-shared/contact.o .obj/release-shared/event.o .obj/release-shared/timeconversion.o .obj/release-shared/palmtoprecord.o .obj/release-shared/task.o .obj/release-shared/passwordbase_p.o .obj/release-shared/categoryeditbase_p.o .obj/release-shared/moc_menubutton.o .obj/release-shared/moc_fileselector.o .obj/release-shared/moc_qpeapplication.o .obj/release-shared/moc_qpedialog.o .obj/release-shared/moc_tzselect.o .obj/release-shared/moc_storage.o .obj/release-shared/moc_qpemenubar.o .obj/release-shared/moc_qpetoolbar.o .obj/release-shared/moc_categories.o .obj/release-shared/moc_categorymenu.o .obj/release-shared/moc_categoryselect.o .obj/release-shared/moc_imageedit.o .obj/release-shared/moc_datebookmonth.o .obj/release-shared/moc_ir.o .obj/release-shared/moc_process.o .obj/release-shared/moc_fileselector_p.o .obj/release-shared/moc_categoryedit_p.o .obj/release-shared/moc_qpedecoration_p.o .obj/release-shared/moc_bgexport_p.o .obj/release-shared/moc_qlibrary_p.o .obj/release-shared/moc_passwordbase_p.o .obj/release-shared/moc_categoryeditbase_p.o -lcrypt -luuid -lm -ldl -ldl -L/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/lib -L/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/lib -lqte
/usr/bin/ld: cannot find -luuid
collect2: ld returned 1 exit status
make[5]: *** [../../../lib/libqpe.so.1.5.3] Error 1
make[5]: Leaving directory `/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/src/libraries/qtopia'
解决方法:
缺少luuid,安装uuid-dev即可解决:
# sudo apt-get install uuid-dev
make[6]: Entering directory `/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/src/plugins/codecs/wavplugin'
g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -Os -fPIC -DQTOPIA_DATA_LINKING -DQCONFIG="qconfig-qpe.h" -DQTOPIA_TARGET="wavplugin" -DQTOPIA_TRTARGET="libwavplugin" -DQT_NO_DEBUG -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/mkspecs/qws/linux-generic-g++ -I. -I../../../3rdparty/libraries/gsm -I../../../../include -I/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qt2/include -I.ui/release-shared/ -I.moc/release-shared/ -o .obj/release-shared/wavplugin.o wavplugin.cpp
wavplugin.cpp: In member function ‘virtual bool WavPlugin::isFileSupported(const QString&)’:
wavplugin.cpp:435: error: invalid conversion from ‘const char*’ to ‘char*’
make[6]: *** [.obj/release-shared/wavplugin.o] Error 1
make[6]: Leaving directory `/opt/EmbedSky/Qte/x86-qtopia-2.2.0/qtopia/src/plugins/codecs/wavplugin'
解决方法:
修正/x86-qtopia-2.2.0/qtopia/src/plugins/codecs/wavplugin/wavplugin.cpp:435行
char *ext = strrchr( path.latin1(), '.' );
改为
char *ext = (char*)strrchr( path.latin1(), '.' );