Hello,
I want to compile my own program on Kamikaze trunk (r22286) with lib owcapi, but it does not work.
Here is my program files:
package/owcapi-test/
package/owcapi-test/Makefile
package/owcapi-test/src
package/owcapi-test/src/Makefile
package/owcapi-test/src/owcapi-test.c
package/owcapi-test/Makefile
I added DEPENS line with owfs and "-L", "-I" and "-l" paramaters in CFLAGS line with owfs directory
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id: Makefile 8659 2007-09-07 08:34:51Z nico $
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=owcapi-test
PKG_RELEASE:=1
PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
# Rajout pour owcapi
PKG_BUILD_DEPENDS:=owfs
define Package/owcapi-test
SECTION:=utils
CATEGORY:=Utilities
TITLE:=owcapi-test
DEPENDS:=+owfs
endef
define Package/owcapi-test/description
This package contains owcapi-test
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
# $(BUILD_DIR) = "/usr/local/tampon/fox-sdk/openwrt/trunk/build_dir/target-cris_uClibc-0.9.30.1"
# $(STAGING_DIR) = "/usr/local/tampon/fox-sdk/openwrt/trunk/staging_dir/target-cris_uClibc-0.9.30.1"
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS) -Dtarget_$(BOARD)=1 -I$(BUILD_DIR)/owfs-2.7p21/ipkg-install/usr/include -L$(BUILD_DIR)/owfs-2.7p21/ipkg-install/usr/lib -lowcapi"
endef
define Package/owcapi-test/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/owcapi-test $(1)/usr/bin
endef
$(eval $(call BuildPackage,owcapi-test))
package/owcapi-test/src/Makefile
owcapi-test: owcapi-test.o
clean:
rm -f owcapi-test *.o *~
package/owcapi-test/src/owcapi-test.c
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <owcapi.h>
int main(int argc, char **argv)
{
char *s;
size_t n;
printf("Starting OW_init\n");
if ( OW_init("localhost:4304") != 0) //Returns: 0 for success. -1 on error and errno will be set. OW_finish does not need to be called if OW_init fails.
{
fprintf(stderr, "Init errror OWFS : %s\n", strerror(errno)) ;
exit(1) ;
}
else
{
OW_set_error_print("2") ; // Sets where the debug output should be directed. 0=mixed output, 1=syslog, 2=console.
OW_set_error_level("6") ; // Sets the debug output to a certain level. 0 is default, and higher value gives more output.
// (0=default, 1=err_connect, 2=err_call, 3=err_data, 4=err_detail, 5=err_debug, 6=err_beyond)
printf("Init ok\n") ;
if ( OW_get("/28.2CAED7010000/temperature",&s,&n) > 0 ) // Returns: number of bytes on success. -1 on error (and errno is set).
{
printf("Temp = '%s'",s);
free(s) ;
}
else
{
free(s) ;
fprintf(stderr, "Read error OWFS : %s\n", strerror(errno));
exit(1) ;
}
}
OW_finish() ;
printf("OW Finish\n") ;
exit(0) ;
}
Output of compilation in verbose mode:
trunk$ make package/owcapi-test/compile V=99
...
make[3]: Entering directory `/usr/local/tampon/fox-sdk/openwrt/trunk/build_dir/linux-etrax/owcapi-test'
cris-openwrt-linux-uclibc-gcc -Os -pipe -funit-at-a-time -fhonour-copts -Dtarget_etrax=1 -I/usr/local/tampon/fox-sdk/openwrt/trunk/build_dir/target-cris_uClibc-0.9.30.1/owfs-2.7p21/ipkg-install/usr/include -L/usr/local/tampon/fox-sdk/openwrt/trunk/build_dir/target-cris_uClibc-0.9.30.1/owfs-2.7p21/ipkg-install/usr/lib -lowcapi -c -o owcapi-test.o owcapi-test.c
cris-openwrt-linux-uclibc-gcc owcapi-test.o -o owcapi-test
owcapi-test.o: In function `main':
owcapi-test.c:(.text+0x1e): undefined reference to `OW_init'
owcapi-test.c:(.text+0x5e): undefined reference to `OW_set_error_print'
owcapi-test.c:(.text+0x6a): undefined reference to `OW_set_error_level'
owcapi-test.c:(.text+0x86): undefined reference to `OW_get'
owcapi-test.c:(.text+0xb4): undefined reference to `OW_finish'
collect2: ld returned 1 exit status
make[3]: *** [owcapi-test] Error 1
make[3]: Leaving directory `/usr/local/tampon/fox-sdk/openwrt/trunk/build_dir/linux-etrax/owcapi-test'
make[2]: *** [/usr/local/tampon/fox-sdk/openwrt/trunk/build_dir/linux-etrax/owcapi-test/.built] Error 2
make[2]: Leaving directory `/usr/local/tampon/fox-sdk/openwrt/trunk/package/owcapi-test'
make[1]: *** [package/owcapi-test/compile] Error 2
make[1]: Leaving directory `/usr/local/tampon/fox-sdk/openwrt/trunk'
make: *** [package/owcapi-test/compile] Error 2
it seems he can not find the library so that the path is well marked.
The include and lib files are present:
$ l /usr/local/tampon/fox-sdk/openwrt/trunk/build_dir/target-cris_uClibc-0.9.30.1/owfs-2.7p21/ipkg-install/usr/include
total 8,0K
-rw-r--r-- 1 dan dan 3,8K 19 août 00:41 owcapi.h
-rw-r--r-- 1 dan dan 3,2K 19 août 00:41 owfs_config.h
$ l /usr/local/tampon/fox-sdk/openwrt/trunk/build_dir/target-cris_uClibc-0.9.30.1/owfs-2.7p21/ipkg-install/usr/lib
total 1,6M
lrwxrwxrwx 1 dan dan 19 19 août 00:41 libow-2.7.so.21 -> libow-2.7.so.21.0.0*
-rwxr-xr-x 1 dan dan 585K 19 août 00:41 libow-2.7.so.21.0.0*
-rw-r--r-- 1 dan dan 909K 19 août 00:41 libow.a
lrwxrwxrwx 1 dan dan 23 19 août 00:41 libowcapi-2.7.so.21 -> libowcapi-2.7.so.21.0.0*
-rwxr-xr-x 1 dan dan 55K 19 août 00:41 libowcapi-2.7.so.21.0.0*
-rw-r--r-- 1 dan dan 5,9K 19 août 00:41 libowcapi.a
-rwxr-xr-x 1 dan dan 1,4K 19 août 00:41 libowcapi.la*
lrwxrwxrwx 1 dan dan 23 19 août 00:41 libowcapi.so -> libowcapi-2.7.so.21.0.0*
-rwxr-xr-x 1 dan dan 1,2K 19 août 00:41 libow.la*
lrwxrwxrwx 1 dan dan 19 19 août 00:41 libow.so -> libow-2.7.so.21.0.0*
I've forgotten something ?
thanks for your help