mips平台交叉编译live555

本文介绍如何在MIPS平台上编译live555源码,并解决编译过程中遇到的locale相关函数缺失问题。通过修改配置文件config.mips并添加-DLOCALE_NOT_USED标志来成功编译。

live555源码下载地址:http://www.live555.com/liveMedia/public/

1、   cp config.armlinux  config.mips文件的属性和内容

修改config.mips文件内容:

CROSS_COMPILE?=         mips-linux-gnu- //这里写你自己的交叉编译器

COMPILE_OPTS =          $(INCLUDES) -I. -O2-DSOCKLEN_T=socklen_t -DXLOCALE_NOT_USED=1  -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64

C =                     c

C_COMPILER =            $(CROSS_COMPILE)gcc

C_FLAGS =               $(COMPILE_OPTS)

CPP =                   cpp

CPLUSPLUS_COMPILER =    $(CROSS_COMPILE)g++

CPLUSPLUS_FLAGS =       $(COMPILE_OPTS) -Wall -DBSD=1

OBJ =                   o

LINK =                  $(CROSS_COMPILE)g++ -o

LINK_OPTS =

CONSOLE_LINK_OPTS =     $(LINK_OPTS)

LIBRARY_LINK =          $(CROSS_COMPILE)ar cr

LIBRARY_LINK_OPTS =     $(LINK_OPTS)

LIB_SUFFIX =                    a

LIBS_FOR_CONSOLE_APPLICATION =

LIBS_FOR_GUI_APPLICATION =

EXE =

 

2、   在live555根目录下运行./genMakefiles  mips

3、  在live555根目录下执行make

4、编译报错及解决办法:

报错:  

../liveMedia/libliveMedia.a(Locale.o): In function `Locale::~Locale()':

Locale.cpp:(.text+0x28): undefined reference to `uselocale'
Locale.cpp:(.text+0x30): undefined reference to `freelocale'
../liveMedia/libliveMedia.a(Locale.o): In function `Locale::Locale(char const*, LocaleCategory)':
Locale.cpp:(.text+0xa8): undefined reference to `newlocale'
Locale.cpp:(.text+0xb4): undefined reference to `uselocale'
collect2: error: ld returned 1 exit status
make[1]: *** [testMPEG4VideoStreamer] Error 1
make[1]: Leaving directory `/home/beihj/live555/live/testProgs'

make: *** [all] Error 2


查看liveMedia/include/Locale.hh文件,有如下信息:

// If you're on a system that (for whatever reason) doesn't have either the "setlocale()" or the "newlocale()" function, then
// add "-DLOCALE_NOT_USED" to your "config.*" file.


// If you're on a system that (for whatever reason) has "setlocale()" but not "newlocale()", then
// add "-DNEWLOCALE_NOT_USED" to your "config.*" file.
// (Note that -DLOCALE_NOT_USED implies -DNEWLOCALE_NOT_USED; you do not need both.)
// Also, for Windows systems, we define "NEWLOCALE_NOT_USED" by default, because at least some Windows systems
// (or their development environments) don't have "newlocale()".  If, however, your Windows system *does* have "newlocale()",
// then you can override this by defining "NEWLOCALE_USED" before #including this file.


// Finally, some old development environments need a header file "xlocale.h" to use "newlocale()".
// Should you need this header file, add "-DNEED_XLOCALE_H" to your "config.*" file.

解决办法:

我的系统跟local相关的函数都没有,根据liveMedia/include/Locale.hh提示修改config.mips给COMPILE_OPTS 添加-DLOCALE_NOT_USED。如果是其他情况,请根据提示修改config.mips即可。

COMPILE_OPTS = $(INCLUDES) -I. -O2 -DSOCKLEN_T=socklen_t -DNO_SSTREAM=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DLOCALE_NOT_USED

驱动器 D 中的卷是 LINUX 卷的序列号是 4471-561B D:\桌面\mips交叉编译环境 的目录 2009-10-22 20:27 <DIR> . 2009-10-22 20:27 <DIR> .. 2009-10-22 20:09 27,425,338 gcc-3.4.3.tar.bz2 2009-10-22 20:08 7,421,782 binutils-2.10.91.0.2.tar.bz2 2009-10-22 20:08 242,445 glibc-linuxthreads-2.5.tar.bz2 2009-10-22 20:10 20,544,628 glibc-2.5.tar.gz 2009-10-22 20:20 1,720 elf-machine-rela-mips.dpatch 2009-10-22 20:26 4,727 建立基于linux的MIPS交叉编译环境 .txt 6 个文件 55,640,640 字节 2 个目录 6,793,084,928 可用字节 三、构建过程 1、准备环境 目标平台: mipsel-linux(即little endian,x86也是little endian的,不懂的话自己到网上查资料吧) 安装目录: /usr/local/crossdev 源代码安装目录: /usr/local/src 注:没有的目录请自行建立。 2、准备MIPS环境的头文件 我们是在i386下编译的,但要使用MIPS的头文件定义才能正确编译MIPS交叉编译工具。这些头文件都在kernel源程序中。 cd /usr/local/src/ tar xzvf linux-2.4.2.tar.gz cd linux/ make ARCH=mips menuconfig 在"CPU selection"中, 选中"(R3000) CPU type",也可以选你实际的MIPS平台的CPU类型 在"General setup"中, 选中"Generate little endian code" make dep mkdir -p /usr/local/crossdev/mipsel-linux/include cp -r /usr/local/src/linux/include/asm-mips /usr/local/crossdev/mipsel-linux/include/asm cp -r /usr/local/src/linux/include/linux /usr/local/crossdev/mipsel-linux/include/ 3、编译binutils cd /usr/local/src/ tar xzvf binutils-2.11.90.0.31.tar.gz cd binutils-2.11.90.0.31/ ./configure --target=mipsel-linux --prefix=/usr/local/crossdev make make install export PATH=/usr/local/crossdev/bin:$PATH 4、编译自举的(bootstrap)gcc 因为这时还没有MIPS的glibc库可以使用,只能编译一个最简单的gcc,用这个gcc编译出glibc后就可以再编译一个完成的gcc了。 cd /usr/local/src/ tar xzvf gcc-3.0.2.tar.gz cd gcc-3.0.2/ ./configure --target=mipsel-linux --prefix=/usr/local/crossdev --enable-languages=c --with-newlib --disable-shared make make install 注:以上编译安装的工具已经可以直接编译MIPS的kernel(make zImage)了。 5、编译glibc 现在可以使用刚才建立的binutils和gcc来编译MIPS的glibc了。 cd /usr/local/src/ tar xzvf glibc-2.2.3.tar.gz cd glibc-2.2.3/ tar xzvf ../glibc-linuxthreads-2.2.3.tar.gz patch -p1 < ../glibc-2.2.3-mips-base-addr-got.diff CC=mipsel-linux-gcc AR=mipsel-linux-ar RANLIB=mipsel-linux-ranlib ./configure --host=mipsel-linux --prefix=/usr/local/crossdev/mipsel-linux --enable-add-ons=linuxthreads make make install 6、重新编译完整的gcc cd /usr/local/src/ rm -rf gcc-3.0.2/ tar xzvf gcc-3.0.2.tar.gz cd gcc-3.0.2/ ./configure --target=mipsel-linux --prefix=/usr/local/crossdev --enable-languages=c,c++ make make install 以上就构建好了一套自己的MIPS交叉编译环境,目录在/usr/local/crossdev下,你可以把它打包拷贝到其它i386的Linux系统下也能使用。 要使用其来交叉编译时请先加上PATH环境变量:export PATH=/usr/local/crossdev/bin:$PATH
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值