我有一个 buildroot 创建的文件系统,我正在尝试在 lighttpd 服务器上执行一些 c 代码。
我创建了一个简单的 C 模块,它只打印出几行 html。代码如下所示:
#include "stdio.h"
int main(void) {
printf( "Content-Type: text/plain\n\n" );
printf("testing C code\n");
return 0;
}
我正在使用来自 Ubuntu 存储库的编译器来编译它arm-linux-gnueabi-gcc -o test.cgi test.c
。如果我用 flag 编译-static
,它会运行得很好,我可以看到显示的 html。但是在没有静态标志的情况下编译,执行失败如下:
# ./test.cgi
-sh: ./first.cgi: not found
我想知道原因是否是 c 库错误,我应该链接到由 buildroot 编译的 uClibc。在我的 buildroot 文件夹output/host/usr/arm-unknown-linux-uclibcgnueabi/sysroot/lib
中,我可以看到以下文件:
-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
是libuClibc-0.9.33.2.so
我要找的文件吗?我怎样才能将我的应用程序与它联系起来?
在我的目标板上,我可以在/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