OpenWrt Forum Archive

Topic: Libxerces-c package

The content of this topic has been archived on 27 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello,

I'm trying to create a libxerces-c package for backfire. As I'm not very experienced with building OpenWrt I just created a simple makefile to see if it appears when I run "make menuconfig", but  I can't   see it listed under Libraries.

This is the makefile.

#
# Copyright (C) 2006-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

# Name and release number of this package
PKG_NAME:=xerces-c
PKG_VERSION:=3.1.1
PKG_RELEASE:=1

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://apache.mirror.pop-sc.rnp.br/apache//xerces/c/3/sources/
PKG_CAT:=zcat

include $(INCLUDE_DIR)/package.mk

# Specify package information for this program. 
# The variables defined here should be self explanatory.
define Package/libxerces
  SECTION:=libs
  CATEGORY:=Libraries
  TITLE:=Validating XML parser written in a portable subset of C++.
  URL:=http://xerces.apache.org/
endef

define Package/libxerces/description
  Xerces-C++ is a validating XML parser written in a portable subset of
C++.  Xerces-C++ makes it easy to give your application the ability 
to read and write XML data. A shared library is provided for parsing,
generating, manipulating, and validating XML documents. Xerces-C++ is
faithful to the XML 1.0 recommendation and associated standards (DOM
1.0, DOM 2.0, SAX 1.0, SAX 2.0, Namespaces, XML Schema Part 1 and
Part 2).  It also provides experimental implementations of XML 1.1
and DOM Level 3.0.  The parser provides high performance, modularity,
and scalability.
endef     

CONFIGURE_ARGS+= --host=mips-openwrt-linux

define Build/Configure
  $(call Build/Configure/Default)    
endef

define Build/Compile
  $(call Build/Compile/Default)
endef

define Package/libxerces/install
endef

$(eval $(call BuildPackage,libxerces))
.

Can someone tell me what's wrong with that MakeFile?

Hi,

with this changed Makefile, I was able to compile the package for a MIPS platform:

#
# Copyright (C) 2006-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

# Name and release number of this package
PKG_NAME:=xerces-c
PKG_VERSION:=3.1.1
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://apache.mirror.pop-sc.rnp.br/apache//xerces/c/3/sources/

PKG_FIXUP:=libtool
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1

include $(INCLUDE_DIR)/package.mk

# Specify package information for this program. 
# The variables defined here should be self explanatory.
define Package/libxerces
  SECTION:=libs
  CATEGORY:=Libraries
  TITLE:=Validating XML parser written in a portable subset of C++.
  URL:=http://xerces.apache.org/
endef

define Package/libxerces/description
  Xerces-C++ is a validating XML parser written in a portable subset of
  C++.  Xerces-C++ makes it easy to give your application the ability 
  to read and write XML data. A shared library is provided for parsing,
  generating, manipulating, and validating XML documents. Xerces-C++ is
  faithful to the XML 1.0 recommendation and associated standards (DOM
  1.0, DOM 2.0, SAX 1.0, SAX 2.0, Namespaces, XML Schema Part 1 and
  Part 2).  It also provides experimental implementations of XML 1.1
  and DOM Level 3.0.  The parser provides high performance, modularity,
  and scalability.
endef     

define Package/libxerces/install
    #
endef

$(eval $(call BuildPackage,libxerces))

Your next steps should be to fill the "Package/libxerces/install" (or "Build/InstallDev") parts, check for the correct dependencies, maybe add some configure options to reduce them, ...

Good luck!

PS: Feel free to send the final package to the developers list (openwrt-devel@lists.openwrt.org, needs registration)

(Last edited by tl71 on 7 Feb 2013, 20:31)

Hi, thanks for your answer. Now I can see the package, but I'm having another problem when trying to compile.

When I run

 make package/libxerces-c/compile V=99 

It gives me the following error

make[1]: Entering directory `/home/eder/work/openwrt/backfire'
make[2]: Entering directory `/home/eder/work/openwrt/backfire/package/libxerces-c'
CFLAGS="-Os -pipe -mips32r2 -mtune=mips32r2 -funit-at-a-time -fhonour-copts -msoft-float  -I/home/eder/work/openwrt/backfire/staging_dir/target-mips_r2_uClibc-0.9.30.1/usr/include -I/home/eder/work/openwrt/backfire/staging_dir/target-mips_r2_uClibc-0.9.30.1/include -I/home/eder/work/openwrt/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/include " CXXFLAGS="-Os -pipe -mips32r2 -mtune=mips32r2 -funit-at-a-time -fhonour-copts -msoft-float  -I/home/eder/work/openwrt/backfire/staging_dir/target-mips_r2_uClibc-0.9.30.1/usr/include -I/home/eder/work/openwrt/backfire/staging_dir/target-mips_r2_uClibc-0.9.30.1/include -I/home/eder/work/openwrt/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/include " LDFLAGS="-L/home/eder/work/openwrt/backfire/staging_dir/target-mips_r2_uClibc-0.9.30.1/usr/lib -L/home/eder/work/openwrt/backfire/staging_dir/target-mips_r2_uClibc-0.9.30.1/lib -L/home/eder/work/openwrt/backfire/staging_dir/toolchain-mips_r2_gcc-4.3.3+cs_uClibc-0.9.30.1/lib " make -C /home/eder/work/openwrt/backfire/build_dir/target-mips_r2_uClibc-0.9.30.1/xerces-c-3.1.1/. AR=mips-openwrt-linux-uclibc-ar AS="mips-openwrt-linux-uclibc-gcc -c -Os -pipe -mips32r2 -mtune=mips32r2 -funit-at-a-time -fhonour-copts -msoft-float" LD=mips-openwrt-linux-uclibc-ld NM=mips-openwrt-linux-uclibc-nm CC="mips-openwrt-linux-uclibc-gcc" GCC="mips-openwrt-linux-uclibc-gcc" CXX="mips-openwrt-linux-uclibc-g++" RANLIB=mips-openwrt-linux-uclibc-ranlib STRIP=mips-openwrt-linux-uclibc-strip OBJCOPY=mips-openwrt-linux-uclibc-objcopy OBJDUMP=mips-openwrt-linux-uclibc-objdump SIZE=mips-openwrt-linux-uclibc-size CROSS="mips-openwrt-linux-uclibc-" ARCH="mips" ;
make[3]: Entering directory `/home/eder/work/openwrt/backfire/build_dir/target-mips_r2_uClibc-0.9.30.1/xerces-c-3.1.1'
make  all-recursive
make[4]: Entering directory `/home/eder/work/openwrt/backfire/build_dir/target-mips_r2_uClibc-0.9.30.1/xerces-c-3.1.1'
Making all in src
make[5]: Entering directory `/home/eder/work/openwrt/backfire/build_dir/target-mips_r2_uClibc-0.9.30.1/xerces-c-3.1.1/src'
make  all-recursive
make[6]: Entering directory `/home/eder/work/openwrt/backfire/build_dir/target-mips_r2_uClibc-0.9.30.1/xerces-c-3.1.1/src'
make[7]: Entering directory `/home/eder/work/openwrt/backfire/build_dir/target-mips_r2_uClibc-0.9.30.1/xerces-c-3.1.1/src'
Compiling xercesc/util/XMLURL.cpp
../libtool: line 42: -c: command not found
Compiling xercesc/util/XMLUTF16Transcoder.cpp
../libtool: line 42: -c: command not found
Compiling xercesc/util/XMLUTF8Transcoder.cpp
../libtool: line 42: -c: command not found

I found this post about the problem, http://comments.gmane.org/gmane.comp.gn … bugs/7048, but the patch is already applied. I tried to put "" around AS=mips-linux-uclibc-gcc -c -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -fhonour-copts, but the error persisits.

PS: Feel free to send the final package to the developers list (openwrt-devel@lists.openwrt.org, needs registration)

That's the idea  smile

Update:

I was able to compile the code, I was putting "" around  AS=mips-linux-uclibc-gcc -c -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -fhonour-copts in the wrong file.

But now I'm having another problem. I compiled another library(libnbee) that depends on libxerces and it was ok. Now I'm trying to compile a program that depends on libnbee, but when I run configure, it gives me errors like this:

/home/eder/work/openwrt/backfire/staging_dir/target-mips_r2_uClibc-0.9.30.1/root-ar71xx//usr/lib/libnbee.so: undefined reference to `xercesc_3_1::XMLPlatformUtils::fgMemoryManager'

running the nm command on libnbee.so shows lots of undefined functions.  How do I link the libraries?

You need to inject -lxerces in LDFLAGS or similar.

I still couldn't compile the application dependent on netbee. I'm still the error mentioned above.

I'm trying to pass the library using the following code on netbee MakeFile

define Build/Configure
    touch Toolchain.cmake
    patch --ignore-whitespace Toolchain.cmake < ./patches/003-Toolchain.patch
    mv Toolchain.cmake $(PKG_BUILD_DIR)/$(PKG_NAME)/src/
    cmake $(PKG_BUILD_DIR)/$(PKG_NAME)/src/nbnetvm/tools/makeopcodetable/CMakeLists.txt
    $(MAKE) -C $(PKG_BUILD_DIR)/$(PKG_NAME)/src/nbnetvm/tools/makeopcodetable/ 
    cmake $(PKG_BUILD_DIR)/$(PKG_NAME)/src/nbnetvm/tools/makenetilscanner/CMakeLists.txt
    $(MAKE) -C $(PKG_BUILD_DIR)/$(PKG_NAME)/src/nbnetvm/tools/makenetilscanner/
    IN_OPENWRT=1 \
    AR="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)ar" \
    AS="$(TOOLCHAIN_DIR)/bin/$(TARGET_CC) -c $(TARGET_CFLAGS)" \
    LD="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)ld -lxerces" \
    NM="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)nm" \
    CC="$(TOOLCHAIN_DIR)/bin/$(TARGET_CC)" \
    GCC="$(TOOLCHAIN_DIR)/bin/$(TARGET_CC)" \
    CXX="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)g++" \
    RANLIB="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)ranlib" \
    STRIP="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)strip" \
    OBJCOPY="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)objcopy" \
    OBJDUMP="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)objdump" \
    TARGET_CPPFLAGS="$(TARGET_CPPFLAGS)" \
    TARGET_CFLAGS="$(TARGET_CFLAGS)" \
    TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \
    cmake $(PKG_BUILD_DIR)/$(PKG_NAME)/src/CMakeLists.txt -DCMAKE_TOOLCHAIN_FILE=Toolchain.cmake
endef

Here is the entire netbee MakeFile

#
# Copyright (C) 2006-2013 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

# Name and release number of this package
PKG_SHORT_NAME:=libnbee
PKG_NAME:=nbeesrc-jan-10-2013
PKG_VERSION:=0.3
PKG_RELEASE:=1

PKG_SOURCE:=nbeesrc-jan-10-2013.zip
PKG_SOURCE_URL:=http://www.nbee.org/download/

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SHORT_NAME)-$(PKG_VERSION)

PKG_UNPACK=unzip -d $(PKG_BUILD_DIR)/ $(DL_DIR)/$(PKG_SOURCE)

PKG_FIXUP:=libtool
PKG_BUILD_PARALLEL:=1


include $(INCLUDE_DIR)/package.mk

# Specify package information for this program. 
# The variables defined here should be self explanatory.
define Package/libnbee
  SECTION:=libs
  CATEGORY:=Libraries
  TITLE:=Netbee library.
  URL:=http://www.nbee.org/
  DEPENDS:=+libxerces +libpcre
endef

define Package/libnbee/description
  NetBee is a new library intended for several types of packet processing, 
  such as packet sniffing and filtering, packet decoding, 
  and traffic classification (not ready yet).
endef     

define Build/Configure
    touch Toolchain.cmake
    patch --ignore-whitespace Toolchain.cmake < ./patches/003-Toolchain.patch
    mv Toolchain.cmake $(PKG_BUILD_DIR)/$(PKG_NAME)/src/
    cmake $(PKG_BUILD_DIR)/$(PKG_NAME)/src/nbnetvm/tools/makeopcodetable/CMakeLists.txt
    $(MAKE) -C $(PKG_BUILD_DIR)/$(PKG_NAME)/src/nbnetvm/tools/makeopcodetable/ 
    cmake $(PKG_BUILD_DIR)/$(PKG_NAME)/src/nbnetvm/tools/makenetilscanner/CMakeLists.txt
    $(MAKE) -C $(PKG_BUILD_DIR)/$(PKG_NAME)/src/nbnetvm/tools/makenetilscanner/
    IN_OPENWRT=1 \
    AR="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)ar" \
    AS="$(TOOLCHAIN_DIR)/bin/$(TARGET_CC) -c $(TARGET_CFLAGS)" \
    LD="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)ld -lxerces" \
    NM="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)nm" \
    CC="$(TOOLCHAIN_DIR)/bin/$(TARGET_CC)" \
    GCC="$(TOOLCHAIN_DIR)/bin/$(TARGET_CC)" \
    CXX="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)g++" \
    RANLIB="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)ranlib" \
    STRIP="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)strip" \
    OBJCOPY="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)objcopy" \
    OBJDUMP="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)objdump" \
    TARGET_CPPFLAGS="$(TARGET_CPPFLAGS)" \
    TARGET_CFLAGS="$(TARGET_CFLAGS)" \
    TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \
    cmake $(PKG_BUILD_DIR)/$(PKG_NAME)/src/CMakeLists.txt -DCMAKE_TOOLCHAIN_FILE=Toolchain.cmake
endef

define Build/Compile
    $(MAKE) -C $(PKG_BUILD_DIR)/$(PKG_NAME)/src LDFLAGS="-L$(STAGING_DIR)/usr/lib" -I$(STAGING_DIR)/usr/include
endef

define Build/InstallDev
    $(INSTALL_DIR) $(1)/usr/include
    $(CP) $(PKG_BUILD_DIR)/$(PKG_NAME)/include/*.h $(1)/usr/include/
    $(INSTALL_DIR) $(1)/usr/lib
    $(CP) $(PKG_BUILD_DIR)/$(PKG_NAME)/bin/libnb* $(1)/usr/lib/
endef

$(eval $(call BuildPackage,libnbee))

Updating:

Compiling netbee for the build machine, I found that when creating the shared objects,  the command is not linking with libxerces-c.

Also there are lots of warnings like this:

/home/eder/work/openwrt/backfire/build_dir/target-mips_r2_uClibc-0.9.30.1/libnbee-0.3/nbeesrc-jan-10-2013/src/nbee/globals/utils.c:1: note: someone does not honour COPTS correctly, passed 0 times

The libxerces-c is installed in  staging_dir/target-mips_r2_uClibc-0.9.30.1/root-ar71xx/usr/lib/ (I would like to know why the makefile are sending to this directory...), while other libraries are installed on  staging_dir/target-mips_r2_uClibc-0.9.30.1/usr/lib. I'm wondering if  the library is not found due to his location.

I also trying to build a package dependent of netbee.

ederlf how you build netbee?
can you share your netbee package with patches and everything?

The discussion might have continued from here.