Hi there,
I'm new to this forum, as also to the development on/for openWRT. I'm working with the kamikaze / armeb release and have severe issues
compiling code and generating an .ipk package using pthread_rwlock_t. Hence my question is: how can I compile code using rwlocks and
generate packages out of it? Or, what am I doing wrong?
For a demonstration I used the first rwlock demo I found in the net, and only adapted it that it runs:
http://publib.boulder.ibm.com/iseries/v5r2/ic2928/index.htm?info/apis/users_86.htm
I wrote the following Makefile. I made a package demo_rwlock-1.1.1.tar.gz and placed
it under dl.
SOURCE = rwlock.c
OBJECTS = $(SOURCE:.c=.o)
CC = gcc
CFLAGS += -g -Wall
%.o: %.c
$(CC) -c $(CFLAGS) $<
rwlock.exe: $(OBJECTS)
$(CC) -o $@ $(OBJECTS) -lm -lpthread
.PHONY: all
all: rwlock.exe
.PHONY: clean
clean:
$(RM) $(OBJECTS) rwlock.exe *~
...I wrote another Makefile for the package:
include $(TOPDIR)/rules.mk
PKG_NAME := demo_rwlock
PKG_VERSION := 1.1.1
PKG_RELEASE := 1
PKG_MD5SUM := c61707196ecda0d625af56b73cfc91d9
PKG_SOURCE_URL := /opt/openwrt/openwrt_8.09/dl/
PKG_SOURCE := $(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_CAT := zcat
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
define Package/demo_rwlock
SECTION:=demos
CATEGORY:=demo codes
TITLE:=demo rwlock
endef
define Package/demo_rwlock/description
a rwlock demo
endef
define Package/demo_rwlock/compile
$(MAKE) -C $(PKG_BUILD_DIR) $(TARGET_CONFIGURE_OPTS)
endef
define Package/demo_rwlock/install
$(INSTALL_DIR) $(1)/root
$(INSTALL_BIN) $(PKG_BUILD_DIR)/rwlock.exe $(1)/root/
endef
$(eval $(call BuildPackage,demo_rwlock))
I've marked the package in .config via make menuconfig as '*'; as also libpthread is turned on.
And when I try to compile I got the following (line 12 only contains "pthread_rwlock_t rwlock;"):
make[1]: Entering directory `/opt/openwrt/openwrt_8.09'
make[2]: Entering directory `/opt/openwrt/openwrt_8.09/package/demo_rwlock'
gzip -dc /opt/openwrt/openwrt_8.09/dl/demo_rwlock-1.1.1.tar.gz | /bin/tar -C /opt/openwrt/openwrt_8.09/build_dir/armeb/demo_rwlock-1.1.1/.. -xf -
touch /opt/openwrt/openwrt_8.09/build_dir/armeb/demo_rwlock-1.1.1/.prepared_80a5dd0eb516634cb7eb0298d6349335
CFLAGS="-Os -pipe -march=armv5te -mtune=xscale -funit-at-a-time -fhonour-copts -msoft-float -I/opt/openwrt/openwrt_8.09/staging_dir/armeb/usr/include -I/opt/openwrt/o\
penwrt_8.09/staging_dir/armeb/include " CXXFLAGS="-Os -pipe -march=armv5te -mtune=xscale -funit-at-a-time -fhonour-copts -msoft-float -I/opt/openwrt/openwrt_8.09/staging_dir/armeb/usr/incl\
ude -I/opt/openwrt/openwrt_8.09/staging_dir/armeb/include " LDFLAGS="-L/opt/openwrt/openwrt_8.09/staging_dir/toolchain-armeb_gcc4.1.2/lib -L/opt/\
openwrt/openwrt_8.09/staging_dir/armeb/usr/lib -L/opt/openwrt/openwrt_8.09/staging_dir/armeb/lib " make -C /opt/openwrt/openwrt_8.09/build_dir/armeb/demo_rwlock-1.1.1/\
. AR=armeb-linux-uclibc-ar AS="armeb-linux-uclibc-gcc -c -Os -pipe -march=armv5te -mtune=xscale -funit-at-a-time -fhonour-copts -msoft-float" LD=armeb-linux-uclibc-ld NM=armeb-linux-uclibc-nm CC="armeb-linux-ucl\
ibc-gcc" GCC="armeb-linux-uclibc-gcc" CXX="armeb-linux-uclibc-g++" RANLIB=armeb-linux-uclibc-ranlib STRIP=armeb-linux-uclibc-strip OBJCOPY=armeb-linux-uclibc-objcopy OBJDUMP=armeb-linux-uclibc-objdump SIZE=armeb\
-linux-uclibc-size CROSS="armeb-linux-uclibc-" ARCH="armeb" ;
make[3]: Entering directory `/opt/openwrt/openwrt_8.09/build_dir/armeb/demo_rwlock-1.1.1'
armeb-linux-uclibc-gcc -c -Os -pipe -march=armv5te -mtune=xscale -funit-at-a-time -fhonour-copts -msoft-float -I/opt/openwrt/openwrt_8.09/staging_dir/armeb/usr/include -I/opt/openwrt/openwrt_8.09/staging_dir/armeb/include -g -Wall rwlock.c
rwlock.c:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'rwlock'
rwlock.c: In function 'rdlockThread':
rwlock.c:25: warning: implicit declaration of function 'pthread_rwlock_rdlock'
rwlock.c:25: error: 'rwlock' undeclared (first use in this function)
rwlock.c:25: error: (Each undeclared identifier is reported only once
rwlock.c:25: error: for each function it appears in.)
rwlock.c:32: warning: implicit declaration of function 'pthread_rwlock_unlock'
rwlock.c: In function 'wrlockThread':
rwlock.c:43: warning: implicit declaration of function 'pthread_rwlock_wrlock'
rwlock.c:43: error: 'rwlock' undeclared (first use in this function)
rwlock.c: In function 'main':
rwlock.c:61: warning: implicit declaration of function 'pthread_rwlock_init'
rwlock.c:61: error: 'rwlock' undeclared (first use in this function)
rwlock.c:97: warning: implicit declaration of function 'pthread_rwlock_destroy'
make[3]: *** [rwlock.o] Error 1
make[3]: Leaving directory `/opt/openwrt/openwrt_8.09/build_dir/armeb/demo_rwlock-1.1.1'
make[2]: *** [/opt/openwrt/openwrt_8.09/build_dir/armeb/demo_rwlock-1.1.1/.built] Error 2
make[2]: Leaving directory `/opt/openwrt/openwrt_8.09/package/demo_rwlock'
make[1]: *** [package/demo_rwlock/compile] Error 2
make[1]: Leaving directory `/opt/openwrt/openwrt_8.09'
make: *** [package/demo_rwlock-compile] Error 2
What is going on here? Why doesn't it know about pthread_rwlock_t? How can I get this code compiled?
I even set -D __USE_UNIX98=1 -D __USE_XOPEN2K=1, nevertheless the corresponding functions remain unknown. Anybody can help me with that please?
thanks in advance