Hello,
this might be easy at the end but tricky for me now, any help is well received, .
I have a program written in C in Linux that sniffes using the pcap library. I want to port it to OpenWrt (Whiterussian) but I'm stuck in the part of compiling the package. I installed the libpcap library on the system (a Linksys WRT54G) so I hope it won't be any problem after I manage to compile the package.
Right now my package is a single file that sniffes on the eth0 port and prints some debug messages, nothing complicated. The makefile compiles from the sources, not a tar or zip file as fancy programmers might do.
Right now the makefile of the package looks like this:
------------------------------------------------------------------------------------------------------------
include $(TOPDIR)/rules.mk
# Name and release number of this package
PKG_NAME:=sniffsip
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/sniffsip
SECTION:=utils
CATEGORY:=Utilities
TITLE:=sniffsip -- Sniff SIP packets
DESCRIPTION:=\
If you can't figure out what this program does, \\\
you're probably brain-dead and need immediate \\\
medical attention.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
LIBS=" -lpcap -nodefaultlibs -lgcc -lc" \
LDFLAGS="$(EXTRA_LDFLAGS)" \
CFLAGS="$(TARGET_CFLAGS) -nostdinc++" \
$(TARGET_CONFIGURE_OPTS) \
CROSS="$(TARGET_CROSS)" \
ARCH="$(ARCH)" \
$(1);
endef
define Package/sniffsip/install
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/sniffsip $(1)/bin/
endef
$(eval $(call BuildPackage,sniffsip))
-----------------------------------------------------------------------------------------------------------------------------
My makefile might not be the best one but has worked for my previous applications. Until I needed something like with this particular one, where I need to somehow link the pcap library.
When compiling using the SDK, I get the following errors:
-----------------------------------------------------------------------------------------------------------------------------
... (something...)
mipsel-linux-uclibc-gcc -c sniffsip.c -lpcap
sniffsip.c:91:18: pcap.h: No such file or directory
sniffsip.c:157: error: parse error before '*' token
sniffsip.c:157: warning: data definition has no type or storage class
sniffsip.c:181: warning: "struct pcap_pkthdr" declared inside parameter list
sniffsip.c:181: warning: its scope is only this definition or declaration, which is probably not what you want
sniffsip.c: In function `main':
sniffsip.c:188: error: `PCAP_ERRBUF_SIZE' undeclared (first use in this function)
sniffsip.c:188: error: (Each undeclared identifier is reported only once
... (something...)
-------------------------------------------------------------------------------------------------------------------------------
So the compiler doesn't find the pcap.h. I have tried putting the -lpcap option on different parts so that the compiler links the library and finds the pcap.h header file. But nothing has worked.
Does somebody has any clue about how to solve this?????
thanks a lot!!!
Miguel