问题
I have a buildroot created file system, and I am trying to execute some c-code on lighttpd server.
I have created a simple C module that just prints out few lines of html. Code looks like this:
#include "stdio.h"
int main(void) {
printf( "Content-Type: text/plain\n\n" );
printf("testing C code\n");
return 0;
}
I'm using compiler from Ubuntu repository, to compile it arm-linux-gnueabi-gcc -o test.cgi test.c
. If I compile with -static
flag, it will run just fine, and I can see the html displayed.
But compiling without the static flag, the execution fails like this:
# ./test.cgi
-sh: ./first.cgi: not found
I am wondering if the reason is wrong a c-library, and I should link against the uClibc that was compiled by buildroot.
In my buildroot folder output/host/usr/arm-unknown-linux-uclibcgnueabi/sysroot/lib
I can see following files:
-rwxr-xr-x 1 jlumme jlumme 25444 Jan 26 17:13 ld-uClibc-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme 21 Jan 26 17:12 ld-uClibc.so.0 -> ld-uClibc-0.9.33.2.so
-rwxr-xr-x 1 jlumme jlumme 13191 Jan 26 17:13 libcrypt-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme 20 Jan 26 17:13 libcrypt.so.0 -> libcrypt-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme 21 Jan 26 17:13 libc.so.0 -> libuClibc-0.9.33.2.so
-rwxr-xr-x 1 jlumme jlumme 13383 Jan 26 17:13 libdl-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme 17 Jan 26 17:13 libdl.so.0 -> libdl-0.9.33.2.so
-rw-r--r-- 1 jlumme jlumme 135 Jan 26 17:15 libgcc_s.so
-rw-r--r-- 1 jlumme jlumme 180152 Jan 26 17:15 libgcc_s.so.1
-rwxr-xr-x 1 jlumme jlumme 64555 Jan 26 17:13 libm-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme 16 Jan 26 17:13 libm.so.0 -> libm-0.9.33.2.so
-rwxr-xr-x 1 jlumme jlumme 4772 Jan 26 17:13 libnsl-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme 18 Jan 26 17:13 libnsl.so.0 -> libnsl-0.9.33.2.so
-rwxr-xr-x 1 jlumme jlumme 79059 Jan 26 17:13 libpthread-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme 22 Jan 26 17:13 libpthread.so.0 -> libpthread-0.9.33.2.so
-rwxr-xr-x 1 jlumme jlumme 4776 Jan 26 17:13 libresolv-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme 21 Jan 26 17:13 libresolv.so.0 -> libresolv-0.9.33.2.so
-rwxr-xr-x 1 jlumme jlumme 13927 Jan 26 17:13 librt-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme 17 Jan 26 17:13 librt.so.0 -> librt-0.9.33.2.so
-rwxr-xr-x 1 jlumme jlumme 284451 Jan 26 17:13 libuClibc-0.9.33.2.so
-rwxr-xr-x 1 jlumme jlumme 4955 Jan 26 17:13 libutil-0.9.33.2.so
lrwxrwxrwx 1 jlumme jlumme 19 Jan 26 17:13 libutil.so.0 -> libutil-0.9.33.2.so
Is the libuClibc-0.9.33.2.so
file that I'm looking for ?
How can I link my application against that ?
In my target board, I can see this in /usr/lib
lrwxrwxrwx 1 root root 15 Jan 26 2013 libbz2.so -> libbz2.so.1.0.6
lrwxrwxrwx 1 root root 15 Jan 26 2013 libbz2.so.1 -> libbz2.so.1.0.6
lrwxrwxrwx 1 root root 15 Jan 26 2013 libbz2.so.1.0 -> libbz2.so.1.0.6
-rwxrwxr-x 1 root root 57924 Jan 26 2013 libbz2.so.1.0.6
lrwxrwxrwx 1 root root 16 Jan 26 2013 libelf.so -> libelf.so.0.8.12
lrwxrwxrwx 1 root root 16 Jan 26 2013 libelf.so.0 -> libelf.so.0.8.12
-rwxr-xr-x 1 root root 69924 Jan 26 2013 libelf.so.0.8.12
lrwxrwxrwx 1 root root 16 Jan 26 2013 libpcre.so -> libpcre.so.1.0.0
lrwxrwxrwx 1 root root 16 Jan 26 2013 libpcre.so.1 -> libpcre.so.1.0.0
-rwxr-xr-x 1 root root 88804 Jan 26 2013 libpcre.so.1.0.0
lrwxrwxrwx 1 root root 19 Jan 26 2013 libpcrecpp.so -> libpcrecpp.so.0.0.0
lrwxrwxrwx 1 root root 19 Jan 26 2013 libpcrecpp.so.0 -> libpcrecpp.so.0.0.0
-rwxr-xr-x 1 root root 27436 Jan 26 2013 libpcrecpp.so.0.0.0
lrwxrwxrwx 1 root root 21 Jan 26 2013 libpcreposix.so -> libpcreposix.so.0.0.0
lrwxrwxrwx 1 root root 21 Jan 26 2013 libpcreposix.so.0 -> libpcreposix.so.0.0.0
-rwxr-xr-x 1 root root 5576 Jan 26 2013 libpcreposix.so.0.0.0
lrwxrwxrwx 1 root root 19 Jan 26 2013 libsqlite3.so -> libsqlite3.so.0.8.6
lrwxrwxrwx 1 root root 19 Jan 26 2013 libsqlite3.so.0 -> libsqlite3.so.0.8.6
-rwxr-xr-x 1 root root 516472 Jan 26 2013 libsqlite3.so.0.8.6
lrwxrwxrwx 1 root root 19 Jan 26 2013 libstdc++.so -> libstdc++.so.6.0.14
lrwxrwxrwx 1 root root 19 Jan 26 2013 libstdc++.so.6 -> libstdc++.so.6.0.14
-rwxr-xr-x 1 root root 418936 Jan 26 2013 libstdc++.so.6.0.14
-rw-r--r-- 1 root root 2422 Jan 26 2013 libstdc++.so.6.0.14-gdb.py
lrwxrwxrwx 1 root root 16 Jan 26 2013 libxml2.so -> libxml2.so.2.8.0
lrwxrwxrwx 1 root root 16 Jan 26 2013 libxml2.so.2 -> libxml2.so.2.8.0
-rwxr-xr-x 1 root root 1063556 Jan 26 2013 libxml2.so.2.8.0
drwxrwxr-x 2 root root 4096 Jan 26 2013 lighttpd
-rw-r--r-- 1 root root 195 Jan 26 2013 xml2Conf.sh
回答1:
To build your application, you have to use the cross-compiler that Buildroot has generated, located in output/host/usr/bin/<name-of-architecture>-gcc
.
Here, you're using the Ubuntu ARM cross-compiler, that targets a system that uses the eglibc
C library. But the system generated with Buildroot uses the uClibc
C library. Therefore, there is absolutely no chance for a binary built with the Ubuntu ARM cross-compiler to run on this Buildroot generated system.
Just use the cross-compiler Buildroot has generated for you.
来源:https://stackoverflow.com/questions/14535897/buildroot-file-system-cross-compiling-dynamically-linked-application-fails-bu