Cross-compiling for ARM with Autoconf

早过忘川 提交于 2019-12-28 05:53:05

问题


I am having trouble cross-compiling a library for my arm board using autconf.

I am using this line:

./configure --target=arm-linux --host=arm-linux --prefix=/bla/bla/bla/linux_arm_tool CFLAGS='-m32'
make
make install

When I do file to check it I get:

libjpeg.so.8.4.0: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped

That doesn't seem right at all, but I tried using it anyway... and I get:

/usr/lib/gcc/arm-linux-gnueabi/4.5.3/../../../../arm-linux-gnueabi/bin/ld: skipping incompatible /bla/bla/bla/bla/../linux_arm_tool/lib/libjpeg.so when searching for -ljpeg

I'm at a loss, I've been googling for an hour now...


回答1:


So I knew I've cross compiled before using really basic method calls and I figured out why I've gotten away with this before after examining the output:

checking for arm-linux-gnueabi-gcc... no
checking for gcc... gcc
...
...
checking for arm-linux-gnueabi-gcc... gcc

In my /usr/bin there was no arm-linux-gnueabi-gcc, I had to:

ln -s /usr/bin/arm-linux-gnueabi-gcc-4.5 /usr/bin/arm-linux-gnueabi-gcc

I successfully cross-compiled using:

./configure --host=arm-linux-gnueabi -prefix=${CSTOOL_DIR}/linux_arm_tool

as for linking ... I still have to check some things, but I am going to assume I might need to throw some -rpath-link flags in more advanced compiles.




回答2:


I think the problem could be restated more generally as: "How do I use Autoconf to cross compile for ARM?"

According to ./configure -h:

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]

The official GNU documentation is helpful for answering this question:

http://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Hosts-and-Cross_002dCompilation.html

Note when they defining the usage of --host and and --build:

Therefore, whenever you specify --host, be sure to specify --build too.

And here is an example that I just used to configure iperf for my embedded ARM platform:

First of all the "./configure" script is actually called "Autoconf" which really helps for google-ing. The idea here is to:

  • Have your cross compilers in your current $PATH
  • Set the CC and CXX environment variables to point to the cross compilers
  • Give the right --host and --build

    buildpath    <--- my little script to setup my $PATH
    export CC=arm_v5t_le-gcc
    export CXX=arm_v5t_le-g++
    ./configure --host=armv5tl-montavista-linux-gnueabi --build=x86_64-linux-gnu
    



回答3:


You need to override the environment variables CC, LD, and other pertinent ones. Setting those switches doesn't tell configure where your cross tool chain is (it could be anywhere)

Check out some guides for various projects, for instance: http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux

Also, here is a script I made to setup cross compile for node.js - same idea: https://gist.github.com/edhemphill/5094239

The libjpeg is not going to work b/c it's a x86 binary, you need it to say:

 ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, not stripped

or similar.

This is the reason you are getting a skipping incompatible




回答4:


# Install arm-linux-gnueabi packages
apt-get install libc6-armel-cross libc6-dev-armel-cross \
binutils-arm-linux-gnueabi arm-linux-gnueabi-gcc libncurses5-dev

./configure --target=arm-linux-gnueabi --host=arm-linux-gnueabi
...
checking for arm-linux-gnueabi-gcc... arm-linux-gnueabi-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether arm-linux-gnueabi-gcc accepts -g... yes
checking for arm-linux-gnueabi-gcc option to accept ISO C89... none needed
checking whether arm-linux-gnueabi-gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of arm-linux-gnueabi-gcc... gcc3
...

make
arm-linux-gnueabi-gcc -DPACKAGE_NAME=\"Tutorial\ Program\" -DPACKAGE_TARNAME=\"tutorial-program\" -DPACKAGE_VERSION=\"1.0\" -DPACKAGE_STRING=\"Tutorial\ Program\ 1.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"tutorial-program\" -DVERSION=\"1.0\" -I.     -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c


来源:https://stackoverflow.com/questions/15234959/cross-compiling-for-arm-with-autoconf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!