Appweb use ESP extend C function on uClinux


Description: HowTo about use ESP extend C function in appweb on winbond uClinux.
Environment:
appweb version: 2.4.1-0
Winbond W90N745(ARM7TDMI);
uClinux 2.4.20;
arm-elf-gcc 3.3.4 in Winbond W90N745 BSP
uClibc 0.9.28 in Winbond W90N745 crosstool

Auth: Guo Wenxue ([email protected])
Version: 1.0.0 (Draft)
Date: 2008.7.11

###############################################################################################

1, edit test code appweb-src-2.4.1/samples/C /simpleEsp/simpleEsp.cpp as:

[code]
#include "appweb/appweb.h"

int helloWorld(EspRequest *ep, int argc, char **argv)
{
espWriteString(ep, "success: C procedure output here in simpleEsp: Hello World !");
return 0;
}
[/code]

###############################################################################################

2, edit appweb-src-2.4.1/samples/C /simpleEsp/Makefile as:

[code]
BUILD_NATIVE := 0
EXPORT_OBJECTS := 0
NAME := simpleEsp

include make.dep

MAKE_IFLAGS := -I$(BLD_TOP)/appweb -I$(BLD_TOP)/http \
-I$(BLD_TOP)/http/modules -I$(BLD_TOP)/esp \
-I$(BLD_TOP)/http/modules/gaCompat \
-I$(BLD_TOP)/ejs -I$(BLD_TOP)/mpr

compileExtra: $(NAME)$(BLD_OBJ)

$(NAME)$(BLD_OBJ): $(NAME).cpp

install:
cp $(NAME)$(BLD_OBJ) $(BLD_TOP)/obj/arm-winbond-linux

distclean:
rm -f $(NAME)
rm -f $(NAME).o
[/code]

################################################################################################

3, edit appweb-src-2.4.1/appweb/appweb.h, add my function declaration in appweb.h

// Forward Declaration, add by guowenxue
int helloWorld(EspRequest *ep, int argc, char **argv);


################################################################################################

4, edit appweb-src-2.4.1/appweb/Makefile, add ../obj/arm-winbond-linux/simpleEsp.o, refer to
Howto-appweb2uClinux.

[code]
# Link standard appweb program. Linked with shared libraries supporting
# dynamic loading of modules.
#
$(BLD_BIN_DIR)/$(BLD_PRODUCT)$(BLD_EXE):
/usr/local/arm_tools_3.3.4/bin/arm-elf-g -o ../bin/arm-winbond-linux/appweb -Wall -Wl,-elf2flt
='-s 204800' -L../lib/arm-winbond-linux ../obj/arm-winbond-linux/appweb.o ../obj/arm-winbond-linux/r
omFiles.o ../obj/arm-winbond-linux/simpleEsp.o ../obj/arm-winbond-linux/appwebStaticLink.o ../lib/ar
m-winbond-linux/libappwebStatic.a
@echo " cp $(BLD_BIN_DIR)/$(BLD_PRODUCT)$(BLD_EXE) $(BLD_PRODUCT)$(BLD_EXE)"
@cp $(BLD_BIN_DIR)/$(BLD_PRODUCT)$(BLD_EXE) $(BLD_PRODUCT)$(BLD_EXE)

# Test appweb program. Linked with shared libraries using dynamic
# loading for all modules.
[/code]

#################################################################################################

5, edit appweb-src-2.4.1/appweb/appweb.cpp

about line :159, add my function forward declaration:

[code]
////////////////////////////// Forward Declarations ////////////////////////////

// add by guowenxue
extern int helloWorld(EspRequest *ep, int argc, char **argv);
[/code]


about line: 593, declare my function in realMain():

[code]
// add by guowenxue
espDefineStringCFunction(0, "helloWorld", helloWorld, 0);

if (http->start() < 0) {
[/code]

##################################################################################################


6, First we have to change to appweb-src-2.4.1/samples/C /simpleEsp and do:

#make;make install

It will copy simpleEsp.o to appweb-src-2.4.1/obj/arm-winbond-linux/simpleEsp.o

##################################################################################################

7, Then we change to appweb-src-2.4.1 and do:

#make

In the appweb-src-2.4.1/appweb/Makefile we changed before, it will link simpleEsp.o to appweb
binary excutable file.

##################################################################################################

你可能感兴趣的:(java,linux)