为什么交叉编译 Arm Linux GCC 会出错? [英] Why error in cross compiling Arm Linux GCC?
问题描述
我正在尝试使用 AppWeb,我编写了一个非常简单的程序将 AppWeb 嵌入到我的应用程序中,它使用 AppWeb 库中的一个函数.
I'm trying to use AppWeb, and i wrote a very simple program to embed AppWeb into my application, it's using a function in AppWeb library.
#include <appweb/appweb.h>
int main(int argc, char** argv)
{
return maRunWebServer("appweb.conf");
}
不知道什么时候用gcc(或cc)编译,编译成功.但是,当我交叉编译到 Arm 架构时,一直出错.这是我的 Makefile:
I dont know when I compile with gcc (or cc), it compiled successful. But, when I cross compile to Arm architecture, is have been getting error. This is my Makefile:
CC = gcc
LIBS = lib
FLAG = -lappweb -lmpr
TEST_TARGET = embed-appweb
OBJS = embed-appweb
all: clean compile
compile: run
$(CC) -Wall -L$(LIBS) $(FLAG) -o $(TEST_TARGET) $(OBJS).o
run:
$(CC) -Wall -L$(LIBS) $(FLAG) -c $(OBJS).c
clean:
@rm -rf $(TEST_TARGET) $(TEST_TARGET).trc *.o *~
@echo "Clean complete"
为了交叉编译,我将CC = gcc"替换为CC = arm-linux-gcc".我的问题中的错误是:
I was replace "CC = gcc" to "CC = arm-linux-gcc" in oder to cross compile. The error in my problem is:
arm-linux-gcc -Wall -Llib -lappweb -lmpr -c embed-appweb.c
embed-appweb.c:1:27: error: appweb/appweb.h: No such file or directory
embed-appweb.c: In function 'main':
embed-appweb.c:4: warning: implicit declaration of function 'maRunWebServer'
make: *** [run] Error 1
并且我确定库libappweb.so"存在于我的文件夹lib"中
and i'm sure that the library "libappweb.so" was exist in my folder "lib"
有人可能会告诉我,为什么会出错?并给我一些建议?
Someone may tell me, why it got error? and give me some advice?
谢谢,
推荐答案
你知道gcc的-I选项怎么用吗?
Do you know how to use the -I option of gcc?
您得到的错误是由于编译器 (gcc) 可以找到您想要包含的文件.
The error you are getting is due to the fact that the compiler (gcc) can find the files you wanted to include.
最简单的解决方案是更改 Makefile 中的 FLAG:
Simplest solution would be to change the FLAG in your Makefile:
FLAG = -lappweb -lmpr
到
FLAG = -lappweb -lmpr -I/path/to/my/headers
当然,您必须将/path/to/my/headers 更改为标题所在的真实路径.
Of course you must change /path/to/my/headers to the true path where your headers reside.
这篇关于为什么交叉编译 Arm Linux GCC 会出错?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!