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");
}
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"
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
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?
Thanks,
Do you know how to use the -I option of gcc?
The error you are getting is due to the fact that the compiler (gcc) can find the files you wanted to include.
Simplest solution would be to change the FLAG in your Makefile:
FLAG = -lappweb -lmpr
to
FLAG = -lappweb -lmpr -I/path/to/my/headers
Of course you must change /path/to/my/headers to the true path where your headers reside.
You have to install (or symbolically link) the appweb header into the arm-linux-gcc include tree.
For example, the arm-linux-gcc
command for one of my systems is
$ which arm-linux-gcc
/home/eldk/usr/bin/arm-linux-gcc
So the include files that compiler uses are:
$ arm-linux-gcc -print-search-dirs
install: /home/eldk/usr/lib/gcc/arm-linux-gnueabi/4.2.2/
programs: =/home/eldk/usr/bin/../libexec/gcc/arm-linux-gnueabi/4.2.2/:/home/eldk/usr/bin/../libexec/gcc/:/home/eldk/usr/lib/gcc/arm-linux-gnueabi/4.2.2/:/home/eldk/usr/lib/gcc/arm-linux-gnueabi/4.2.2/:/home/eldk/usr/lib/gcc/arm-linux-gnueabi/:/usr/libexec/gcc/arm-linux-gnueabi/4.2.2/:/usr/libexec/gcc/arm-linux-gnueabi/:/home/eldk/usr/libexec/gcc/arm-linux-gnueabi/4.2.2/:/home/eldk/usr/bin/../lib/gcc/arm-linux-gnueabi/4.2.2/../../../../arm-linux-gnueabi/bin/arm-linux-gnueabi/4.2.2/:/home/eldk/usr/bin/../lib/gcc/arm-linux-gnueabi/4.2.2/../../../../arm-linux-gnueabi/bin/:/home/eldk/usr/lib/gcc/arm-linux-gnueabi/4.2.2/../../../../arm-linux-gnueabi/bin/arm-linux-gnueabi/4.2.2/:/home/eldk/usr/lib/gcc/arm-linux-gnueabi/4.2.2/../../../../arm-linux-gnueabi/bin/
libraries: =/home/eldk/usr/bin/../lib/gcc/arm-linux-gnueabi/4.2.2/:/home/eldk/usr/bin/../lib/gcc/:/home/eldk/usr/lib/gcc/arm-linux-gnueabi/4.2.2/:/usr/libexec/gcc/arm-linux-gnueabi/4.2.2/:/home/eldk/usr/bin/../lib/gcc/arm-linux-gnueabi/4.2.2/../../../../arm-linux-gnueabi/lib/arm-linux-gnueabi/4.2.2/:/home/eldk/usr/bin/../lib/gcc/arm-linux-gnueabi/4.2.2/../../../../arm-linux-gnueabi/lib/:/home/eldk/usr/lib/gcc/arm-linux-gnueabi/4.2.2/../../../../arm-linux-gnueabi/lib/arm-linux-gnueabi/4.2.2/:/home/eldk/usr/lib/gcc/arm-linux-gnueabi/4.2.2/../../../../arm-linux-gnueabi/lib/:/home/eldk/usr/../arm/lib/arm-linux-gnueabi/4.2.2/:/home/eldk/usr/../arm/lib/:/home/eldk/usr/../arm/usr/lib/arm-linux-gnueabi/4.2.2/:/home/eldk/usr/../arm/usr/lib/
You have two concerns:
- Your include search path (as already pointed by sessyargc.jp and wallyk).
- Your library search path.
When you compile using gcc
, it will use your gcc configurations to find out headers and libraries inside its own toolchain. It will default to something like "/usr/include" and "/usr/lib".
When you are compiling with arm-linux-gcc
, as done before by gcc
, it will use your arm-linux-gcc
configurations to find out headers and libraries inside its own toolchain. It can be anywhere, depending on your toolchain (i.e. "/home/eldk/usr/lib/gcc/arm-linux-gnueabi/4.2.2/..." for wallyk's).
Note that you have two different toolchains, and each one has its own files.
You cannot link a library built for "x86" into an ARM binary. They are incompatible!
gcc
links gcc libs, arm-linux-gcc
links arm-linux-gcc libs.
Even the headers, that only plain text, can't be the same, as different processors can have different configurations for endiannes, data sizes, etc.
SO
You must install your AppWeb cross-compiled for ARM before getting to compile your sample application.
After this, you will end up having a appweb/appweb.h
and -lappweb
reachable by your toolchain.
Please tell us if you need help on how to cross-compile AppWeb.
It must be a README in the sources telling how to do that.