Hi all,
I'm having trouble with the SDK; I'd really appreciate it if someone could give me a hand here :-((((
I have a wl-hdd running whiterussian (latest 0.9), and I'm trying to cross-compile a small application on my i686 linux PC, using the OpenWRT-SDK (i took the one from http://downloads.openwrt.org/whiterussi … 1.tar.bz2).
But for whatever reason the .ipk that is generated still seems to contain code for the host (i.e. i686) machine, not for the WL-HDD (mipsel); on the WL-HDD the binary generates an error (/bin/helloworld: 1 Syntax error: "(" unexpected). The same binary, on the i686-PC executes...
I followed the instructions for using the SDK found in http://people.bu.edu/ebishop/openwrt-programming.html (The SDK is installed in "/home/ubuntu/SDK/")
* created a directory in packages (/home/ubuntu/SDK/package/helloworld)
* the helloworld directory contains the Makefile (/home/ubuntu/SDK/package/helloworld/Makefile)
and a src directory containing the application sourcecode (/home/ubuntu/SDK/package/helloworld/src/helloworld.c)
(i don't download the sourcecode, but copy it from src to $(PKG_BUILD_DIR) in Build/Prepare)
* when i execute make in /home/ubuntu/SDK/, everything seems to work, and i find helloworld_1_mipsel.ipk in
/home/ubuntu/SDK/bin/packages. But this ipk doesn't work on the wl-hdd. I transfered it from the PC to the WL-HDD using ftp,
installed it (ipkg install helloworld_1_mipsel.ipk), but binary just generates the syntax error mentioned above. the same binary
(bin/helloworld), transfered back to the PC, executed perfectly. that's why I think that the SDK compiled the package for the i686-host
machine, not for the mipsel. but I have no idea why.
Below I'll post the sourcecode, the makefile and the V=99 output of make; I hope someone can help me here :-(
I also noticed one funny thing, don´t know if it matters: the Makefile in the SDK directory (home/ubuntu/SDK/Makefile) contains a line "RELEASE=Kamikaze", although I downloaded the SDK from the whiterussian directory.
Thanks a lot!!
Chris
==========The sourcecode: /home/ubuntu/SDK/package/helloworld/src/helloworld.c================
#include <stdio.h>
int main(void)
{
printf("Hell! Oh world, why don't my code compile ??\n");
return 0;
}
=================================================
========/home/ubuntu/SDK/package/helloworld/Makefile===========
include $(TOPDIR)/rules.mk
PKG_NAME:=helloworld
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/helloworld
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Helloworld
endef
# copy the source files to the build directory (this is NOT the default)
# The default uses PKG_SOURCE_URL and the PKG_SOURCE to download the source from the web.
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Package/helloworld/install
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/bin/
endef
$(eval $(call BuildPackage,helloworld))
=================================================
===============Output of /home/ubuntu/SDK/make V=99 ============
make package/compile
make[1]: Entering directory `/home/ubuntu/OpenWrt-SDK-Linux-i686-1'
make -C package compile SDK=1
make[2]: Entering directory `/home/ubuntu/OpenWrt-SDK-Linux-i686-1/package'
make -j1 compile-targets
make[3]: Entering directory `/home/ubuntu/OpenWrt-SDK-Linux-i686-1/package'
mkdir -p /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/stamp
mkdir -p /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/root
make -C helloworld compile
Rebuilding /home/ubuntu/OpenWrt-SDK-Linux-i686-1/bin/packages/helloworld_1_mipsel.ipk
make[4]: Entering directory `/home/ubuntu/OpenWrt-SDK-Linux-i686-1/package/helloworld'
mkdir -p /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld
cp -fpR ./src/* /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/
touch /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/.prepared
(cd /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/; if [ -x configure ]; then AR=mipsel-linux-uclibc-ar AS="mipsel-linux-uclibc-gcc -c -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time" LD=mipsel-linux-uclibc-ld NM=mipsel-linux-uclibc-nm CC="mipsel-linux-uclibc-gcc" GCC="mipsel-linux-uclibc-gcc" CXX=mipsel-linux-uclibc-g++ RANLIB=mipsel-linux-uclibc-ranlib STRIP=mipsel-linux-uclibc-strip OBJCOPY=mipsel-linux-uclibc-objcopy CFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time" CXXFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time" CPPFLAGS="-I/home/ubuntu/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/include -I/home/ubuntu/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/include" LDFLAGS="-L/home/ubuntu/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/lib -L/home/ubuntu/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/lib" PKG_CONFIG_PATH="/home/ubuntu/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/lib/pkgconfig" PKG_CONFIG_LIBDIR="/home/ubuntu/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/lib/pkgconfig" ./configure --target=mipsel-linux --host=mipsel-linux --build=i486-linux-gnu --program-prefix="" --program-suffix="" --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --disable-nls ; fi; )
touch /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/.configured
CFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/ubuntu/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/include -I/home/ubuntu/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/include " LDFLAGS="-L/home/ubuntu/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/lib -L/home/ubuntu/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/lib " make -C /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld AR=mipsel-linux-uclibc-ar AS="mipsel-linux-uclibc-gcc -c -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time" LD=mipsel-linux-uclibc-ld NM=mipsel-linux-uclibc-nm CC="mipsel-linux-uclibc-gcc" GCC="mipsel-linux-uclibc-gcc" CXX=mipsel-linux-uclibc-g++ RANLIB=mipsel-linux-uclibc-ranlib STRIP=mipsel-linux-uclibc-strip OBJCOPY=mipsel-linux-uclibc-objcopy CROSS="mipsel-linux-uclibc-" CXXFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/ubuntu/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/usr/include -I/home/ubuntu/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/include " ARCH="mipsel" ;
make[5]: Entering directory `/home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld'
make[5]: `helloworld' is up to date.
make[5]: Leaving directory `/home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld'
touch /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/.built
mkdir -p /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/CONTROL
echo "Package: helloworld" > /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/CONTROL/control
echo "Version: 1" >> /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/CONTROL/control
( DEPENDS=''; for depend in ; do DEPENDS=${DEPENDS:+$DEPENDS, }${depend##+}; done; echo "Depends: $DEPENDS" >> /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/CONTROL/control; )
echo "Source: package/helloworld" >> /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/CONTROL/control
echo "Section: utils" >> /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/CONTROL/control
echo "Priority: optional" >> /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/CONTROL/control
echo "Maintainer: OpenWrt Developers Team <openwrt-devel@openwrt.org>" >> /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/CONTROL/control
echo "Architecture: mipsel" >> /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/CONTROL/control
echo "Description: Helloworld -- prints a snarky message\\ If you can't figure out what this program does, \ you're probably brain-dead and need immediate \ medical attention." | sed -e 's,\\,\n,g' | sed -e 's,^[[:space:]]*$, .,g' >> /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/CONTROL/control
chmod 644 /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/CONTROL/control
(cd /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/CONTROL; var2file "V_Package_helloworld_conffiles" conffiles; var2file "V_Package_helloworld_preinst" preinst; var2file "V_Package_helloworld_postinst" postinst; var2file "V_Package_helloworld_prerm" prerm; var2file "V_Package_helloworld_postrm" postrm; )
install -d -m0755 /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/bin
install -m0755 /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/helloworld /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/bin/
mkdir -p /home/ubuntu/OpenWrt-SDK-Linux-i686-1/bin/packages
find /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld -name CVS | xargs rm -rf
find /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld -name .svn | xargs rm -rf
find /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld -name '.#*' | xargs rm -f
STRIP="/home/ubuntu/OpenWrt-SDK-Linux-i686-1/staging_dir_mipsel/bin/sstrip" STRIP_KMOD="mipsel-linux-uclibc-strip --strip-unneeded --remove-section=.comment" /home/ubuntu/OpenWrt-SDK-Linux-i686-1/scripts/rstrip.sh /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld
rstrip.sh: /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld/bin/helloworld:executable
ipkg-build -c -o 0 -g 0 /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld /home/ubuntu/OpenWrt-SDK-Linux-i686-1/bin/packages
Packaged contents of /home/ubuntu/OpenWrt-SDK-Linux-i686-1/build_mipsel/helloworld/ipkg/helloworld into /home/ubuntu/OpenWrt-SDK-Linux-i686-1/bin/packages/helloworld_1_mipsel.ipk
make[4]: Leaving directory `/home/ubuntu/OpenWrt-SDK-Linux-i686-1/package/helloworld'
make[3]: Leaving directory `/home/ubuntu/OpenWrt-SDK-Linux-i686-1/package'
make[2]: Leaving directory `/home/ubuntu/OpenWrt-SDK-Linux-i686-1/package'
make[1]: Leaving directory `/home/ubuntu/OpenWrt-SDK-Linux-i686-1'
( \
cd package; \
find . -maxdepth 2 -name Config.in | \
sed -e 's,/Config.in,,g' | \
xargs -r -n1 make compile -C; \
)
=================================================