mipsel-linux环境下amule的移植

交叉编译

环境(执行uname –a后):

Host

Linux localhost.localdomain 2.6.18-8.el5xen #1 SMP Fri Jan 26 14:42:21 EST 2007 i686 athlon i386 GNU/Linux

Targets

Linux uclibc 2.6.15-sigma #11 PREEMPT Fri Feb 13 15:05:22 CST 2009 mips unknown

源代码:

wxBase-2.8.9.tar.gz

cryptopp552

aMle-2.2.3.tar.bz2

 

一、wxBase-2.8.9.tar.gz

 

./configure --disable-gui --without-subdirs --enable-unicode --without-expat --host=mipsel-linux --prefix=/home/sutianzhu/proj-mips-linux/install/wxbase/

错误解决:

 Mkdir –p src/xml

cp  xml.cpp  src/xml/

cp include/wx/xml/xml.h

 

二、cryptopp552

1、修改GNUmakefile

A、令CXX = mipsel-linux-g++,注释掉原#CXX = g++(共两处)

BCXX = gcc(在此代码前 添加此语句)

  ifeq ($(CXX),gcc)   # for some reason CXX is gcc on cygwin 1.1.4

  #add mipsel-linux-gcc

  #CXX = g++

  CXX = mipsel-linux-g++

 endif

C、注释掉:#CXXFLAGS += -march=native -mtune=native

后补充:要制定crypto的安装目录:

GNUMakefile中添加:

RANLIB = mipsel-linux-ranlib

  AR = mipsel-linux-ar #add by sutianzhu

PREFIX = "/opt/toolchain/smp86xx_toolchain_2.8.0.1/build_mipsel_nofpu/staging_dir/"

然后在安装amule时候,指定其安装目录:

--with-crypto-prefix="/opt/toolchain/smp86xx_toolchain_2.8.0.1/build_mipsel_nofpu/staging_dir/"

三、 aMle-2.2.3.tar.bz2

 

. ./configure --prefix=/home/sutianzhu/proj-mips-linux/install/amule/ -disable-monolithic --enable-amule-daemon --with-toolkit=base --enable-amulecmd --with-wx-config=/home/sutianzhu/proj-mips-linux/wxBase-2.8.9/wx-config --host=mipsel-linux --with-zlib=/home/sutianzhu/proj-mips-linux/zlib-1.2.3/zlibinstall/ --disable-debug

 

Erro

checking for zlib >= 1.1.4... no

(四、解决缺少zlib库的错误(编译zlib-1.2.1.tar)

./configure --prefix=/home/sutianzhu/proj-mips-linux/install/amule/ -disable-monolithic --enable-amule-daemon --with-toolkit=base --enable-amulecmd --with-wx-config=/home/sutianzhu/proj-mips-linux/install/wxbase/bin/wx-config --host=mipsel-linux --with-zlib=/home/sutianzhu/proj-mips-linux/zlib-1.2.3/zlibinstall

Large file

最新配置文件:

[sutianzhu@localhost aMule-2.2.3]$

 ./configure --prefix=/home/sutianzhu/mips-project/install/amule/ -disable-monolithic --enable-amule-daemon --with-toolkit=base --enable-amulecmd --with-wx-config=/home/sutianzhu/wxWideget/install/wxwideget/bin/wx-config --host=mipsel-linux --with-zlib=/home/sutianzhu/proj-mips-linux/zlib-1.2.3/zlibinstall/  --disable-debug --with-crypto-prefix="/opt/toolchain/smp86xx_toolchain_2.8.0.1/build_mipsel_nofpu/staging_dir/"

四、解决缺少zlib库的错误(编译zlib-1.2.1.tar)

[sutianzhu@localhos          tzlib-1.2.3]$ prefix=/home/sutianzhu/proj-mips-linux/zlib-1.2.3/zlibinstall/  CC=mipsel-linux-gcc ./configure

[sutianzhu@localhos    tzlib-1.2.3] make test && make install

五、在有--with-wx-config=/home/sutianzhu/proj-mips-linux/install/wxbase/bin/wx-config时出现large file错误:

分析:错误原因是,在wxBase的安装目录下少了include文件夹及其下面的内容

 

 

 

 

五、环境变量:

Export LDFLAGS='-L/home/sutianzhu/wxWideget/wxWidgets-2.8.8/lib -L/opt/toolchain/smp86xx_toolchain_2.8.0.1/build_mipsel_nofpu/staging_dir/lib'

USER=root

 

 

六、修改文件:

1ctype_base.h文件

vim /opt/toolchain/smp86xx_toolchain_2.8.0.1/build_mipsel_nofpu/staging_dir/bin-ccache/../lib/gcc/mipsel-linux-uclibc/3.4.2/../../../../include/c++/3.4.2/mipsel-linux-uclibc/bits/ctype_base.h

添加:

#ifndef SJ___

#define SJ__

typedef __uint16_t __ctype_mask_t;//write by sutianzhu

…………

#endif

2locale_facets.h文件

vim /opt/toolchain/smp86xx_toolchain_2.8.0.1/build_mipsel_nofpu/staging_dir/bin-ccache/../lib/gcc/mipsel-linux-uclibc/3.4.2/../../../../include/c++/3.4.2/bits/locale_facets.h

添加:

#ifndef SJ__1

#define SJ__1

      typedef unsigned int* __to_type;//write by sutianzhu

#endif

 

3cstdlib文件

vim /opt/toolchain/smp86xx_toolchain_2.8.0.1/build_mipsel_nofpu/staging_dir/bin-ccache/../lib/gcc/mipsel-linux-uclibc/3.4.2/../../../../include/c++/3.4.2/cstdlib

 

添加:

//#undef malloc //Note by sutianzhu注销掉

//#undef realloc  //Note by sutianzhu

 

// using ::malloc;//by sutianzhu注销掉

// using ::realloc; //by sutianzhu

4amuled.cpp文件:

[root@localhost aMule-2.2.3]# vim src/amuled.cpp

添加如下代码:

//Added by sutianzhu below

#ifdef  __FD_ZERO

#undef __FD_ZERO

#endif

 

#ifdef __FD_SET

#undef __FD_SET

#endif

 

#ifdef __FD_CLR

#undef __FD_CLR

#endif

 

#ifdef __FD_ISSET

#undef __FD_ISSET

#endif

 

typedef long int __fd_mask;

#define __NFDBITS   (8 * sizeof (__fd_mask))

#define __FDELT(d)  ((d) / __NFDBITS)

#define __FDMASK(d) ((__fd_mask) 1 << ((d) % __NFDBITS))

 

#define __FD_ZERO(s) /

do {                                        /

unsigned int __i;                                 /

fd_set *__arr = (s);                              /

for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i)          /

__FDS_BITS (__arr)[__i] = 0;                        /

} while (0)

#define __FD_SET(d, s)     (__FDS_BITS (s)[__FDELT(d)] |= __FDMASK(d))

#define __FD_CLR(d, s)     (__FDS_BITS (s)[__FDELT(d)] &= ~__FDMASK(d))

#define __FD_ISSET(d, s)   ((__FDS_BITS (s)[__FDELT(d)] & __FDMASK(d)) != 0)

//Added by sutianzhu above

extern "C"

{

void __assert_fail(const char*, const char*, unsigned int, const char*)

{

printf("---->>>> ASSERT");

}

}

 

6未起作用的修改:

 

cp /opt/toolchain/smp86xx_toolchain_2.8.0.1/build_mipsel_nofpu/staging_dir/include/sys/select.h   ./

 

cp /opt/toolchain/smp86xx_toolchain_2.8.0.1/build_mipsel_nofpu/staging_dir/include/bits/select.h  ./  【没起作用】

 

7execinfo.h 文件未发现

 

error

MuleDebug.cpp:36:23: execinfo.h: No such file or directory

解决:export CXXFLAGS=-I/usr/include

8__assert_fail 解决之一

 

Error

/opt/toolchain/smp86xx_toolchain_2.8.0.1/build_mipsel_nofpu/staging_dir/bin-ccache/../lib/gcc/mipsel-linux-uclibc/3.4.2/../../../../include/c++/3.4.2/bits/basic_string.h:2022: undefined reference to `__assert_fail

解决:--disable-debug

9、文件连接出现不兼容

 

Error:

Linking amuled

/opt/toolchain/smp86xx_toolchain_2.8.0.1/build_mipsel_nofpu/staging_dir/bin-ccache/../lib/gcc/mipsel-linux-uclibc/3.4.2/../../../../mipsel-linux-uclibc/bin/ld: skipping incompatible /usr/lib/libpthread.so when searching for –lpthread

解决:

Export LDFLAGS= -L /opt/toolchain/smp86xx_toolchain_2.8.0.1/toolchain_build_mipsel_nofpu/uClibc-0.9.27/lib

七、后期错误解决:

现象:

Linking amuled

amuled-ClientCreditsList.o(.gnu.linkonce.t._ZN8CryptoPP11UnsignedMinIjjEEKT_RS2_RKT0_+0x80): In function `unsigned int const CryptoPP::UnsignedMin(unsigned int const&, unsigned int const&)':

: undefined reference to `__assert_fail'

amuled-ClientCreditsList.o(.gnu.linkonce.t._ZN8CryptoPP29FixedSizeAllocatorWithCleanupIjLj16ENS_13NullAllocatorIjEELb0EE10deallocateEPvj+0x94): In function `CryptoPP::FixedSizeAllocatorWithCleanup, false>::deallocate(void*, unsigned int)':

: undefined reference to `__assert_fail'

amuled-ClientCreditsList.o(.gnu.linkonce.t._ZN8CryptoPP29FixedSizeAllocatorWithCleanupIjLj16ENS_13NullAllocatorIjEELb0EE10deallocateEPvj+0xf0): In function `CryptoPP::FixedSizeAllocatorWithCleanup, false>::deallocate(void*, unsigned int)':

: undefined reference to `__assert_fail'

amuled-ClientCreditsList.o(.gnu.linkonce.t._ZN8CryptoPP13NullAllocatorIjE10deallocateEPvj+0x54): In function `CryptoPP::NullAllocator::deallocate(void*, unsigned int)':

: undefined reference to `__assert_fail'

amuled-ClientCreditsList.o(.gnu.linkonce.t._ZN8CryptoPP29FixedSizeAllocatorWithCleanupIjLj32ENS_13NullAllocatorIjEELb0EE10deallocateEPvj+0x94): In function `CryptoPP::FixedSizeAllocatorWithCleanup, false>::deallocate(void*, unsigned int)':

: undefined reference to `__assert_fail'

amuled-ClientCreditsList.o(.gnu.linkonce.t._ZN8CryptoPP29FixedSizeAllocatorWithCleanupIjLj32ENS_13NullAllocatorIjEELb0EE10deallocateEPvj+0xf0): more undefined references to `__assert_fail' follow

collect2: ld returned 1 exit status

make[3]: *** [amuled] Error 1

make[2]: *** [all-recursive] Error 1

make[1]: *** [all-recursive] Error 1

make: *** [all] Error 2

解决:

[root@localhost aMule-2.2.3]# vim src/amuled.cpp

extern "C"

{

void __assert_fail(const char*, const char*, unsigned int, const char*)

{

printf("---->>>> ASSERT");

}

}

八、后续:

make

 LDFLAGS="-L/mnt/sutianzhu/wxWideget/wxWidgets-2.8.8/lib/ -L/opt/toolchain/smp86xx_toolchain_2.8.0.1/toolchain_build_mipsel_nofpu/uClibc-0.9.27/lib" ./configure --prefix=/home/sutianzhu/proj-mips-linux/install/amule/ -disable-monolithic --enable-amule-daemon --with-toolkit=base --enable-amulecmd --with-wx-config=/root/work/wxBase-2.8.9/wx-config --host=mipsel-linux --with-zlib=/root/work/install/zlib/

 

则不用修改的上述文件是:

3cstdlib文件

7execinfo.h 文件未发现

8__assert_fail 解决之一

 

九、调试中的错误

checking for C compiler default output file name... configure: error: C compiler cannot create executables

See `config.log' for more details.

解决:

 mv /lib/libgcc_s.so.1-bak-sj  /lib/libgcc_s.so.1库被修改过

你可能感兴趣的:(交叉编译)