c,c++
分类: 嵌入式
2016-01-06 21:15:04
参考资料:
[1]http://blog.chinaunix.net/uid-22609852-id-3506499.html
[2]
[3]http://linux.chinaunix.net/techdoc/develop/2009/07/07/1122402.shtml
本文是网络资料的整理,把各个版本组合在一起
默认便以为MiniGUI-Threads。编译为MiniGUI-processes需要加--enable--procs
采用交叉编译方式
【软件环境】
PC:redhat5
开发板:AT91SAM9G45
Target: arm-linux-gcc
gcc version 3.4.1
FreeType库:
minigui字体引擎
freetype-2.3.9-fm20100818.tar.gz
JPEG库:
minigui显示jpeg图片
jpegsrc.v7.tar.gz
png库:
minigui显示png图片
libpng-1.2.37.tar.gz
zlib库:
minigui数据压缩函数库
zlib-1.2.2.tar.gz
minigui所用到的资源
minigui-res-be-3_0_12.tar.gz
minigui核心库
libminigui-gpl-3_0_12.tar.gz
minigui样例
mg-samples-3_0_12.tar.gz
虚拟FrameBuffer
qvfb2-2.0.tar.gz
Setp1:
建立工作目录:如/work/minigui,把上面资源*.tar.gz到目录中
cp *.tar.gz /work/minigui
解压文件
Setp2:
[编译Freetype库]
(A)./configure --host=arm-linux --enable-static --prefix=/usr/local/minigui
(有些版本要修改一下Makefile,如freetype-1.3.1,修改如下:
第12行 all: ttlib ttest ttpo为all: ttlib ttpo
第34行 注释(或删)掉,即#cd $(FTTESTDIR); $(MAKE) -f $(MAKEFILE) install
否则make就会出现下面的错误
ftdump.c:172:1: error: pasting "." and "glyph_object" does not give a valid preprocessing token
ftdump.c:182:1: error: pasting "." and "first_instance" does not give a valid preprocessing token
ftdump.c:191:1: error: pasting "." and "second_instance" does not give a valid preprocessing token
ftdump.c:201:1: error: pasting "." and "face_object" does not give a valid preprocessing token
ftdump.c:202:1: error: pasting "." and "glyph_object" does not give a valid preprocessing token
ftdump.c:203:1: error: pasting "." and "second_instance" does not give a valid preprocessing token)
错误2
(
(A)在安装时会有ftdump.c的预处理标识符错误,修改./test/ftdump.c里的 Print_Mem( memory_footprint.##field, string )
(B)改为 : Print_Mem( memory_footprint.field, string )
(C)#define FOOTPRINT( field ) Save_Memory( &memory_footprint.##field )
(D)修改为:#define FOOTPRINT( field ) Save_Memory( &memory_footprint.field )
)
(B)make
(C)make install
[编译JPEG库]
cd jpeg-7
(E)修改configure(vi configure)在文件开始的位置加上
CC=arm-linux-gcc
CXX=arm-linux-g++
LD=arm-linux-ld
AS=arm-linux-as
AR=arm-linux-ar
如(后面的库的编译修改configure亦如此):
## M4sh Initialization. ##
## -------------------- ##
# Be more Bourne compatible
CC=arm-linux-gcc
CXX=arm-linux-g++
LD=arm-linux-ld
AS=arm-linux-as
AR=arm-linux-ar
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
(B)./configure --prefix=/usr/local/minigui --build=i386-linux \
--host=arm-linux --target=arm-linux --enable-shared
(C)make
(D)make install
[编译PNG库]
cd libpng-1.2.37/
(A)修改configure(vi configure)在文件开始的位置加上
CC=arm-linux-gcc
CXX=arm-linux-g++
LD=arm-linux-ld
AS=arm-linux-as
AR=arm-linux-ar
(B)./configure --prefix=/usr/local/minigui --build=i386-linux \
--host=arm-linux --target=arm-linux
(C)make
(D)make install
[编译zlib库]
cd zlib-1.2.2/
(A)修改configure(vi configure)在文件开始的位置加上
CC=arm-linux-gcc
CXX=arm-linux-g++
LD=arm-linux-ld
AS=arm-linux-as
AR=arm-linux-ar
(B)./configure --prefix=/usr/local/minigui --shared
(C)make
(D)make install
[编译资源库]
cd minigui-res-be-3.0.12/
(A)修改configure(vi configure)在文件开始的位置加上
CC=arm-linux-gcc
CXX=arm-linux-g++
LD=arm-linux-ld
AS=arm-linux-as
AR=arm-linux-ar
(B)./configure --prefix=/usr/local/minigui
(C)make
(D)make install
[编译核心库]
cd libminigui-gpl-3.0.12/
(A)修改configure(vi configure)在文件开始的位置加上
CC=arm-linux-gcc
CXX=arm-linux-g++
LD=arm-linux-ld
AS=arm-linux-as
AR=arm-linux-ar
CFLAGS="-I/usr/local/minigui/include -I/opt/FriendlyARM/toolschain/3.4.1/arm-none-linux-gnueabi/include "
CPPFLAGS="-g -I/usr/local/minigui/include -I/opt/FriendlyARM/toolschain/3.4.1/arm-none-linux-gnueabi/include "
CXXFLAGS="-g -I/usr/local/minigui/include -I/opt/FriendlyARM/toolschain/3.4.1/arm-none-linux-gnueabi/include "
(此处要特别注意,我用的编译器所在目录为/opt/FriendlyARM/toolschain/3.4.1,注意跟自己环境的差异,下面的示例库编译亦然)
(B)./configure --prefix=/usr/local/minigui --host=arm-linux \
--target=arm-linux --build=i386-linux --with-osname=linux \
--with-style=classic --with-targetname=fbcon --enable-autoial \
--enable-rbf16 --disable-vbfsupport --enable-tslibial
(上面的--enable-tslibial选项是minigui支持触摸屏必选的选项,后面会讲到)
最后提示:
Going to generate license pictures ...
./configure: line 15541: ./runme.sh: No such file or directory WARNING: failed to generate license pictures. 可以不用管它,继续编译
(C)make
此时会遇到一个错误,关于pcxvfb.c的错误,修改Makefile:src/newgal/pcxvfb/Makefile,把以下两个地方都去掉:
177 oldincludedir = /usr/include
194 INCLUDES = -I$(abs_top_srcdir)/src/include -I$(abs_top_srcdir)/include \
-I$(abs_top_srcdir)/src/newgal/ -I/usr/include
将划掉的删掉
(D)make install
安装结束后,查看下/usr/local/minigui/目录下的 lib 文件夹里是否有libminigui_ths-3.0.so.12、libminigui_ths-3.0.so.12.0.0、libminigui_ths.so等文件
[编译示例库]
cd mg-samples-3.0.12/
(A)修改configure(vi configure)在文件开始的位置加上
CC=arm-linux-gcc
CXX=arm-linux-g++
LD=arm-linux-ld
AS=arm-linux-as
AR=arm-linux-ar
CFLAGS="-I/usr/local/minigui/include -I/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/include "
CPPFLAGS="-g -I/usr/local/minigui/include -I/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/include "
CXXFLAGS="-g -I/usr/local/minigui/include -I/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/include "
(B)./configure --prefix=/usr/local/minigui --build=i386-linux \
--host=arm-linux --target=arm-linux
(C)make
如果有如下错误:
错误1:
checking pkg-config is at least version 0.9.0... yes
checking for MINIGUI... configure: error: Package requirements (minigui >= 3.0.10) were not met:
No package 'minigui' found
}
解决方法:export PKG_CONFIG_PATH=/usr/local/minigui/lib/pkgconfig/
./configure
Make
错误2:
现象
arm-linux-gcc -g -O2 -Wall -Wstrict-prototypes -pipe -D_REENTRANT -o notebook main.o -lmgext -lpthread -lminigui
/usr/local/lib/libminigui.so: undefined reference to
`ts_close'
/usr/local/lib/libminigui.so: undefined reference to
`ts_read'
/usr/local/lib/libminigui.so: undefined reference to
`ts_open'
/usr/local/lib/libminigui.so: undefined reference to `ts_fd'
collect2: ld returned 1 exit status
make[2]: *** [notebook] 错误 1
原因
编译时要加入链接库tslib
修改configure命令
./configure CC=arm-linux-gcc --build=i686-pc-linux --target=arm-linux --host=arm-linux CFLAGS="-
L/usr/local/arm/3.4.1/arm-linux/lib -lts"
错误3:
dlgdemo.c:40:27: 错误:mgplus/mgplus.h:没有那个文件或目录
make[2]: *** [dlgdemo.o] 错误 1
make[2]: Leaving directory `/mnt/hgfs/F/mg-samples-3.0.12/ctrl_dlg'
make[1]: *** [all-recursive] 错误 1
make[1]: Leaving directory `/mnt/hgfs/F/mg-samples-3.0.12/ctrl_dlg'
make: *** [all-recursive] 错误 1
}
解决办法:vim ctrl_dlg/dlgdemo.c ,注释掉mgplus/mgplus.h
make
make install
【安装 qvfb2-2.0.tar.gz 】 README中有安装说明
tar zxvf qvfb2-2.0.tar.gz
cd qvfb2-2.0
./configure
{报错:
checking for Qt... configure: error: Qt (>= Qt 3.0.3) (headers and libraries) not found. Please check your installation!
}
解决办法:需要首先安装一个qt-devel-3.3.8-4.fc7.i386.rpm
rpm -iv qt-devel-3.3.8-4.fc7.i386.rpm --force --nodeps
rm /usr/lib/qt-3.3/lib/libqt-mt.so
ln -s /usr/lib/qt-3.3/lib/libqt-mt.so.3.3.6 /usr/lib/qt-3.3/lib/libqt-mt.so
ls -l /usr/lib/qt-3.3/lib/
如果不知道安装哪一个,可以yum install qt3*,在给出的文件中选择
./configure --with-qt-includes=/usr/lib/qt-3.3/include --with-qt-libraries=/usr/lib/qt-3.3/lib --with-qt-dir=/usr/lib/qt-3.3
make
make install
运行报错:
ScimInputContextPlugin()
WARNING: please edit ~/.scim/global and change /DefaultConfigModule to kconfig
oops:client1 : No such file or directory
~ScimInputContextPlugin()
这个方法只能消除WARNING:用root帐户 修改文件/etc/X11/xinit/xinput.d/aux/scim-qtimm,把QT_IM_MODULE=scim改为QT_IM_MODULE=xim
还是有以下错误
ScimInputContextPlugin()
oops:client1 : No such file or directory
~ScimInputContextPlugin()
最后按README安装成功,不需要预先运行qvfb2, 直接运行你的程序就可以启动,不过还是有错误libpng error: x[DA][EC][BD]: invalid chunk type
__mg_init_png error! // 这个是在redhat5中有错,相同的软件包我在fedora14上按相同步骤就没遇到
但是不影响
[运行时错误]
<12>如果出现错误:
1)InitGUI (step 3): There is already an instance of 'mginit'! 解决方法:sudo rm /var/tmp/mgini 2)LoadSharedResource: File exists
InitGUI (step 8): Can not load shared resource! 段错误
解决办法:ipcs -st
删除列出的信号量:ipcrm -s 信号量id
[运行程序]
gcc -o helloworld helloworld.c -lminigui_ths -ljpeg -lpng -ldl -lm -lpthread
针对miniGUI3.0.12,不加-ldl会报错,错误如下:
/usr/local/lib/libminigui_ths.so: undefined reference to `dlsym'
/usr/local/lib/libminigui_ths.so: undefined reference to `dlerror'
/usr/local/lib/libminigui_ths.so: undefined reference to `dlopen'
/usr/local/lib/libminigui_ths.so: undefined reference to `dlclose'
collect2: ld returned 1 exit status