奇怪了,交叉编译出来了,但是不能运行。
# WSDD - ONVIF WS-Discovery server
## Description
wsdd is Linux daemon for ONVIF WS-Discovery service (server side).
ONVIF official website: [http://www.onvif.org](http://www.onvif.org)
The web services data binding is generated using [gSOAP](http://www.genivia.com)
For more details about it see the [gSOAP WS-Discovery plugin official manual.](https://www.genivia.com/doc/wsdd/html/wsdd_0.html)
项目在github上 wsdd 使用了 gsoap里面的 plugin里面的两个文件
(注意:
GSOAP_PLUGIN_DIR = $(GSOAP_DIR)/plugin
SOAP_SRC = $(GSOAP_DIR)/stdsoap2.c \
$(GSOAP_PLUGIN_DIR)/wsaapi.c \
$(GSOAP_PLUGIN_DIR)/wsddapi.c \
$(GENERATED_DIR)/soapClient.c
)。
GCC_ARM ?= arm-linux-gnueabi-gcc-4.7 (这里修改添加了一个交叉编译器)
define build_object
@$(BUILD_ECHO)
$(GCC_ARM) -c $< -o $@ $(CFLAGS) (使用的交叉编译器 编译依赖的 文件)
endef
define build_bin
@$(BUILD_ECHO)
$(GCC_ARM) $1 -o $@ $(CFLAGS) (使用的交叉编译器 编译连接最终的target)
@echo "\n---- Compiled $@ ver $(DAEMON_MAJOR_VERSION).$(DAEMON_MINOR_VERSION).$(DAEMON_PATCH_VERSION) ----\n"
endef
里面还有一个 GCC ,要注意整个编译过程。 第一部分是先用GCC 编译gSoap的源代码产生两个 WSDL2H ,SOAPCPP2。
这两个是 x86下的程序用来生成我们的 开发框架的。 所以这部分不能交叉编译。
生成的框架和我们的代码都被包含在 SOURCES这个变量里面。
SOAP_SRC = $(GSOAP_DIR)/stdsoap2.c \
$(GSOAP_PLUGIN_DIR)/wsaapi.c \
$(GSOAP_PLUGIN_DIR)/wsddapi.c \
$(GENERATED_DIR)/soapClient.c
# Add your source files to the list.
# Supported *.c *.cpp *.S files.
# For other file types write a template rule for build, see below.
SOURCES = $(COMMON_DIR)/$(DAEMON_NAME).c \
$(COMMON_DIR)/daemon.c \
$(COMMON_DIR)/net_utils.c \
$(COMMON_DIR)/file_utils.c \
$(COMMON_DIR)/wsdd_utils.c \
$(COMMON_DIR)/client_events.c \
$(GENERATED_DIR)/soapC.c \
$(SOAP_SRC)
最后调用
# release
$(DAEMON_NAME): .depend $(OBJECTS)
$(call build_bin, $(OBJECTS))
# debug
$(DAEMON_NAME)_$(DEBUG_SUFFIX): .depend $(DEBUG_OBJECTS)
$(call build_bin, $(DEBUG_OBJECTS))
# Build release objects
%.o: %.c
$(build_object)
%.o: %.cpp
$(build_object)
%.o: %.S
$(build_object)
# Build debug objects
%_$(DEBUG_SUFFIX).o: %.c
$(build_object)
%_$(DEBUG_SUFFIX).o: %.cpp
$(build_object)
%_$(DEBUG_SUFFIX).o: %.S
$(build_object)
build_bin 和 build_object 里面的编译工具已经替换成了 交叉编译工具。最后就可以生成 ARM下的可执行文件了。
DAEMON_NAME = wsdd
DAEMON_MAJOR_VERSION = 2
DAEMON_MINOR_VERSION = 1
DAEMON_PATCH_VERSION = 0
DAEMON_PID_FILE_NAME = $(DAEMON_NAME).pid
DAEMON_LOG_FILE_NAME = $(DAEMON_NAME).log
DAEMON_NO_CHDIR = 1
DAEMON_NO_CLOSE_STDIO = 0
GSOAP_DIR = ./gsoap-2.8/gsoap
GSOAP_PLUGIN_DIR = $(GSOAP_DIR)/plugin
GSOAP_IMPORT_DIR = $(GSOAP_DIR)/import
SOAPCPP2 = $(GSOAP_DIR)/src/soapcpp2
WSDL2H = $(GSOAP_DIR)/wsdl/wsdl2h
COMMON_DIR = ./src
GENERATED_DIR = ./generated
CFLAGS = -DDAEMON_NAME='"$(DAEMON_NAME)"'
CFLAGS += -DDAEMON_MAJOR_VERSION=$(DAEMON_MAJOR_VERSION)
CFLAGS += -DDAEMON_MINOR_VERSION=$(DAEMON_MINOR_VERSION)
CFLAGS += -DDAEMON_PATCH_VERSION=$(DAEMON_PATCH_VERSION)
CFLAGS += -DDAEMON_PID_FILE_NAME='"$(DAEMON_PID_FILE_NAME)"'
CFLAGS += -DDAEMON_LOG_FILE_NAME='"$(DAEMON_LOG_FILE_NAME)"'
CFLAGS += -DDAEMON_NO_CHDIR=$(DAEMON_NO_CHDIR)
CFLAGS += -DDAEMON_NO_CLOSE_STDIO=$(DAEMON_NO_CLOSE_STDIO)
CFLAGS += -I$(COMMON_DIR)
CFLAGS += -I$(GENERATED_DIR)
CFLAGS += -I$(GSOAP_DIR) -I$(GSOAP_PLUGIN_DIR) -I$(GSOAP_IMPORT_DIR)
CFLAGS += -O2 -Wall -pipe
GCC ?= gcc
GCC_ARM ?= arm-linux-gnueabi-gcc-4.7 (这里修改添加了一个交叉编译器)
SOAP_SRC = $(GSOAP_DIR)/stdsoap2.c \
$(GSOAP_PLUGIN_DIR)/wsaapi.c \
$(GSOAP_PLUGIN_DIR)/wsddapi.c \
$(GENERATED_DIR)/soapClient.c
# Add your source files to the list.
# Supported *.c *.cpp *.S files.
# For other file types write a template rule for build, see below.
SOURCES = $(COMMON_DIR)/$(DAEMON_NAME).c \
$(COMMON_DIR)/daemon.c \
$(COMMON_DIR)/net_utils.c \
$(COMMON_DIR)/file_utils.c \
$(COMMON_DIR)/wsdd_utils.c \
$(COMMON_DIR)/client_events.c \
$(GENERATED_DIR)/soapC.c \
$(SOAP_SRC)
OBJECTS := $(patsubst %.c, %.o, $(SOURCES) )
OBJECTS := $(patsubst %.cpp,%.o, $(OBJECTS) )
OBJECTS := $(patsubst %.S, %.o, $(OBJECTS) )
DEBUG_SUFFIX = debug
DEBUG_OBJECTS := $(patsubst %.o, %_$(DEBUG_SUFFIX).o, $(OBJECTS) )
.PHONY: all
all: debug release
.PHONY: release
release: CFLAGS := -s $(CFLAGS)
release: $(DAEMON_NAME)
.PHONY: debug
debug: DAEMON_NO_CLOSE_STDIO = 1
debug: CFLAGS := -DDEBUG -g $(CFLAGS)
debug: $(DAEMON_NAME)_$(DEBUG_SUFFIX)
# release
$(DAEMON_NAME): .depend $(OBJECTS)
$(call build_bin, $(OBJECTS))
# debug
$(DAEMON_NAME)_$(DEBUG_SUFFIX): .depend $(DEBUG_OBJECTS)
$(call build_bin, $(DEBUG_OBJECTS))
# Build release objects
%.o: %.c
$(build_object)
%.o: %.cpp
$(build_object)
%.o: %.S
$(build_object)
# Build debug objects
%_$(DEBUG_SUFFIX).o: %.c
$(build_object)
%_$(DEBUG_SUFFIX).o: %.cpp
$(build_object)
%_$(DEBUG_SUFFIX).o: %.S
$(build_object)
.PHONY: clean
clean:
-@rm -f $(DAEMON_NAME)
-@rm -f $(DAEMON_NAME)_$(DEBUG_SUFFIX)
-@rm -f $(OBJECTS)
-@rm -f $(DEBUG_OBJECTS)
-@rm -f .depend
-@rm -f -d -R $(GENERATED_DIR)
-@rm -f *.*~
.PHONY: distclean
distclean: clean
-@rm -f -d -R SDK
-@rm -f -d -R gsoap-2.8
-@rm -f RECV.log SENT.log TEST.log
.depend: $(GENERATED_DIR)/soapC.c
-@rm -f .depend
@echo "Generating dependencies..."
@for src in $(SOURCES) ; do \
echo " [depend] $$src" ; \
$(GCC) $(CFLAGS) -MT ".depend $${src%.*}.o $${src%.*}_$(DEBUG_SUFFIX).o" -MM $$src >> .depend ; \
done
ifeq "$(findstring $(MAKECMDGOALS),clean distclean)" ""
include $(wildcard .depend)
endif
# ---- gSOAP ----
$(GENERATED_DIR)/wsdd.h:
@$(build_gsoap)
@mkdir -p $(GENERATED_DIR)
$(WSDL2H) -cg -t $(GSOAP_DIR)/WS/typemap.dat -o $@ wsdl/remotediscovery.wsdl
$(GENERATED_DIR)/soapC.c: $(GENERATED_DIR)/wsdd.h
$(SOAPCPP2) -C -L -x -c -2 -d $(GENERATED_DIR) -I$(GSOAP_DIR):$(GSOAP_IMPORT_DIR) $<
# This targets is needed for parallel work of make
$(OBJECTS) $(DEBUG_OBJECTS) $(SOAP_SRC): $(GENERATED_DIR)/soapC.c
# Common commands
BUILD_ECHO = echo "\n [build] $@:"
define build_object
@$(BUILD_ECHO)
$(GCC_ARM) -c $< -o $@ $(CFLAGS) (使用的交叉编译器 编译依赖的 文件)
endef
define build_bin
@$(BUILD_ECHO)
$(GCC_ARM) $1 -o $@ $(CFLAGS) (使用的交叉编译器 编译连接最终的target)
@echo "\n---- Compiled $@ ver $(DAEMON_MAJOR_VERSION).$(DAEMON_MINOR_VERSION).$(DAEMON_PATCH_VERSION) ----\n"
endef
define build_gsoap
# get archive
if [ ! -f SDK/gsoap.zip ]; then \
mkdir -p SDK; \
wget -O ./SDK/gsoap.zip.tmp "https://sourceforge.net/projects/gsoap2/files/gsoap-2.8/gsoap_2.8.66.zip/download" && \
mv ./SDK/gsoap.zip.tmp ./SDK/gsoap.zip; \
fi
# unzip
if [ ! -f gsoap-2.8/README.txt ]; then \
unzip ./SDK/gsoap.zip; \
fi
# build
if [ ! -f $(SOAPCPP2) ] || [ ! -f $(WSDL2H) ]; then \
cd gsoap-2.8; \
./configure && \
make -j1; \
cd ..;\
fi
endef
.PHONY: help
help:
@echo "make [command]"
@echo "command is:"
@echo " all - build daemon in release and debug mode"
@echo " debug - build in debug mode (#define DEBUG 1)"
@echo " release - build in release mode (strip)"
@echo " clean - remove all generated files"
@echo " distclean - clean + remove all SDK files"
@echo " help - this help"