Results 1 to 12 of 12

Thread: [HOW TO] Compile a program for your router

  1. #1
    Join Date
    Dec 2007
    Location
    The Netherlands - Eindhoven
    Posts
    1,767

    Post [HOW TO] Compile a program for your router

    To use this how to, you have to use a set up like in the how to from wengi or something similair.
    This is the way to compile a package on Oleg, I''m still trying to do one on puppylinux (or others) with the tool chain.

    All the credits to Dr.Chair who explained it to me

    first step:
    make sure everything is updated
    choose "N" if promted with a question
    ipkg update
    ipkg upgrade
    now we have to install some packages, about 80MB!
    ipkg install optware-devel
    ipkg install buildroot
    if you get any errors, try the command again or use
    -force-overwrite
    behind the commands


    Now we need a package to compile, I changed dosbox to apache in this tutorial because I couldn''t get dosbox working.
    Apache also would be more usefull

    Download the source (or search for a recent version) here:
    http://www.apache.org/dist/httpd/httpd-2.2.8.tar.bz2

    Open the file with winrar and copy the files via samba on your disc.
    Note that you can also unpack this file on the router (not explained here)

    I''ve uploaded the file to /mnt/share/apache
    cd to the directory
    cd /mnt/share/apache
    you need an additional packages for apache to make the compile successfull, check the manual of the program you want to compile wich package it needs and search for it on ipkgfind
    ipkg install apr
    ipkg install apr-util
    ipkg install e2fsprogs
    ipkg install expat
    ipkg install openssl
    ipkg install zlib
    ipkg install openldap-libs
    now we can finally hit the configure:
    This took me about half a hour
    ./configure --prefix=/opt
    now make the files:
    make
    and make install
    make install
    well... basicly this is the way you should compile on the router.
    In my next post I will try to tell you how to do it on ubuntu and puppy linux, or other distributions.
    have fun
    Last edited by wpte; 11-06-2008 at 15:00.

  2. #2
    Join Date
    Dec 2007
    Location
    The Netherlands - Eindhoven
    Posts
    1,767
    When you have problems making the configured files you can try one of these commands behind it:
    -b, -m Ignored for compatibility.
    -B, --always-make Unconditionally make all targets.
    -C DIRECTORY, --directory=DIRECTORY
    Change to DIRECTORY before doing anything.
    -d Print lots of debugging information.
    --debug[=FLAGS] Print various types of debugging information.
    -e, --environment-overrides
    Environment variables override makefiles.
    -f FILE, --file=FILE, --makefile=FILE
    Read FILE as a makefile.
    -h, --help Print this message and exit.
    -i, --ignore-errors Ignore errors from commands.
    -I DIRECTORY, --include-dir=DIRECTORY
    Search DIRECTORY for included makefiles.
    -j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg.
    -k, --keep-going Keep going when some targets can't be made.
    -l [N], --load-average[=N], --max-load[=N]
    Don't start multiple jobs unless load is below N.
    -L, --check-symlink-times Use the latest mtime between symlinks and target.
    -n, --just-print, --dry-run, --recon
    Don't actually run any commands; just print them.
    -o FILE, --old-file=FILE, --assume-old=FILE
    Consider FILE to be very old and don't remake it.
    -p, --print-data-base Print make's internal database.
    -q, --question Run no commands; exit status says if up to date.
    -r, --no-builtin-rules Disable the built-in implicit rules.
    -R, --no-builtin-variables Disable the built-in variable settings.
    -s, --silent, --quiet Don't echo commands.
    -S, --no-keep-going, --stop
    Turns off -k.
    -t, --touch Touch targets instead of remaking them.
    -v, --version Print the version number of make and exit.
    -w, --print-directory Print the current directory.
    --no-print-directory Turn off -w, even if it was turned on implicitly.
    -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
    Consider FILE to be infinitely new.
    --warn-undefined-variables Warn when an undefined variable is referenced.
    so if you have errors this command might help:
    make -m --ignore-errors --keep-going
    this might give you an incomplete program tho

    ################################################## ####################

    If you want to share compiled files with other people you can try to use a defferent prefix.
    the prefix is where the program will be installed

    example:
    mkdir /opt/temp
    ./configure --prefix=/opt/temp
    now all the files will be installed to /opt/temp
    after it's installed you can pack the file in zip, rar or other compression systems and send it to other ppl.
    in most cases the content of this folder needs to be extracted to /opt
    also keep in mind that some libraries have a config file wich need to be changed.

    example:
    libupnp has a file: /lib/pkgconfig/libupnp.pc
    make sure to edit this file and change the line to this:
    prefix=/opt
    ################################################## ####################

    if you think you get errors because the files for compiling sources are damaged, you can try this:
    ipkg update
    ipkg install -force-overwrite -force-reinstall optware-devel autoconf automake bash bison bzip2 coreutils diffutils file findutils flex gawk groff libstdc++ libtool make m4 ncurses openssl patch perl pkgconfig python rsync sed svn tar wget-ssl buildroot
    ################################################## ####################

    If you downloaded the source from SVN you need to create the configure file yourself by:
    cd /the/source/dir
    autoconf
    you can add additional settings like these:
    autoconf --force --output=configuration-file
    Last edited by wpte; 17-07-2008 at 00:18.

  3. #3
    Looks like this might of worked out however you might want to add about installing the grep and sed packages. While busybox has built-in ones compile scripts are going to be expecting ones to be available outside of the shell provided one. At least that was the case for when I wanted to compile the xcache extension for php.

    Oh and yes it did compile. I'll be doing testing later today. I had successfully ran through the phpBB3 install using eaccelerator but hit a brick wall when all it did was generate a white page. Edit: Err... or maybe not. I wonder if I had issues installing xcache before....
    Last edited by shinji257; 09-06-2008 at 00:17.

  4. #4
    Join Date
    Dec 2007
    Location
    The Netherlands - Eindhoven
    Posts
    1,767
    Quote Originally Posted by shinji257 View Post
    Looks like this might of worked out however you might want to add about installing the grep and sed packages. While busybox has built-in ones compile scripts are going to be expecting ones to be available outside of the shell provided one. At least that was the case for when I wanted to compile the xcache extension for php.

    Oh and yes it did compile. I'll be doing testing later today. I had successfully ran through the phpBB3 install using eaccelerator but hit a brick wall when all it did was generate a white page. Edit: Err... or maybe not. I wonder if I had issues installing xcache before....
    what do you mean with info about installing the grep and sed packages?
    busybox doesn't have build in compile scripts as far as I know, you first need to download those via ipkg.

    Xcache is for heavy loaded servers, so might be nice to have on a slow server
    but if it works... I think the only difference you can see is the page generation time?
    if something doesn't work I always try an earlier version or modificate something in the configure scripts, it sometimes helps

  5. #5
    Quote Originally Posted by wpte View Post
    what do you mean with info about installing the grep and sed packages?
    busybox doesn't have build in compile scripts as far as I know, you first need to download those via ipkg.

    Xcache is for heavy loaded servers, so might be nice to have on a slow server
    but if it works... I think the only difference you can see is the page generation time?
    if something doesn't work I always try an earlier version or modificate something in the configure scripts, it sometimes helps
    No. I mean that when you go to compile something else it will complain about grep and/or sed missing even though busybox provides them. It is due to the fact that they use bash to run I think. An individual will likely have to install those packages. Xcache failed to compile correctly and I did have issues compiling it on a different server. On the other hand I did get APC to compile fine however it doesn't work. Therefore I am sticking with eaccelerator. The php cache is to help speed up the load times a little. Maybe I'll compile up the new version when I get a chance.

  6. #6
    Join Date
    Dec 2007
    Location
    The Netherlands - Eindhoven
    Posts
    1,767
    well... as some people might notice, I've updated my first story with a different package.
    This package, took me about... 1 hour to compile
    but it does work!
    I'm making progress with the toolchain, so I should be able to post something in the coming days

  7. #7

    Lightbulb

    There already is a toolchain available.

    I run Debian in VMware on a Windows PC to compile my code.

    This howto works great for me: Cross-Compilieren von IPK Packeten

  8. #8
    Right. There is a difference in how the compile is approached however. This thread is about how to compile the programs natively right on the router. The thread you pointed to says how to cross-compile it on your computer using Linux. I prefer native compiles when I can however some programs may need to be cross-compiled due to missing implementations in the toolchain (wordexp() being one).

    Oops. That one shows how to make ipkg sets. My bad. Anyways I am going to try the instructions at the following pages to do native ipkg builds. Wish me luck.

    http://www.nslu2-linux.org/wiki/FAQ/Optware-uClibcBuild
    http://www.nslu2-linux.org/wiki/Optw...ckageToOptware

    Note that the first time I tried the router crashed but I think it was because it was trying to put a bunch of stuff in /usr/local/root/downloads and that is all held in memory. I've added a symlink to point to my drive and committed it to the flashfs file.

    I noted this though. It happens after it gets the initial cross compile package (crosstool-0.38.tar.gz) though.

    In file nslu2-cross335.sh

    TARBALLS_DIR=$HOME/downloads

    This defines the download location. Note that in the case of the router I still have the home folder set to /usr/local/root. I honestly don't know what would happen if I changed that location. In the main script it is $BUILD_ROOT/downloads where BUILD_ROOT is the location you have the optware repository retrieved to. I also spotted crosstool-cygwin.sh in the setup which tells me that it may work in cygwin. Worth a shot I think.

    EDIT: Second shot fails at this

    Code:
    sh scripts/Configure -d arch/arm/config.in
    Configure requires bash
    make[1]: *** [oldconfig] Error 1
    make[1]: Leaving directory `/tmp/mnt/disc0_3/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/linux-2.4.22'
    make: *** [/tmp/mnt/disc0_3/optware/toolchain/crosstool/.built] Error 2
    Note that what I found interesting was that it needed bash (which is installed) but also that it was called using sh. Not all systems use bash as sh however may have it installed. A better route might of been `which bash` which would of executed bash regardless of the location. Even just "env bash" (no quotes) would of worked. Both were much more cross platform than just using sh and making an assumption it would be bash then letting the configure script stop if it isn't. In the meantime I have symlinked /opt/bin/sh to /opt/bin/bash and will try and see if this band-aid takes care of it. I'm also going to see if it will work under cygwin as well as I hope.

    http://www.kegel.com/crosstool/curre...to.html#cygwin

    This indicates that it should work at least on that level. Just wonder about the rest of the stuff...

    For cygwin I had to "mount" a managed folder that cygwin would handle directly. This results in some odd filenames due to utf-8 translation and special handling of odd filenames and lengths that exceed windows limits. If worse come to worse I'll have to go back and remount /usr/bin and /usr/lib.
    Last edited by shinji257; 18-06-2008 at 18:55.

  9. #9
    Quote Originally Posted by shinji257 View Post
    It happens after it gets the initial cross compile package (crosstool-0.38.tar.gz) though.
    I think you forgot to export OPTWARE_TARGET=oleg

    Cause crosstool isn't needed for compiling ipkg's for oleg

  10. #10
    Quote Originally Posted by DrChair View Post
    I think you forgot to export OPTWARE_TARGET=oleg

    Cause crosstool isn't needed for compiling ipkg's for oleg
    Actually I did do that. I don't know why it is getting that for a native run. All I want is to build proper ipkg sets.

    EDIT: Oops. I looked at http://www.nslu2-linux.org/wiki/Optw...ckageToOptware again and it seems that I didn't need to do most of what I have done. I checked the commands and ran these on the router....

    svn co http://svn.nslu2-linux.org/svnroot/optware/trunk optware
    cd optware
    make oleg-target
    cd oleg
    make directories ipkg-utils

    Now in theory once you do that and you have the .mk file done correctly you can go to optware/oleg and run make <package name> and it will compile it immediately including dependencies followed by building the ipkg. On the router it will being the compile right away and use the buildroot package items however under cygwin it has downloaded the buildroot sources and started compiling them. I'll have it run through the night and see where it goes.

    This builds it up for making ipkg sets. I'll modify the existing php one creating new entires for iconv and gmp extensions. gmp will have libgmp as a dependency and iconv will have gconv-modules as a dependency. I'll also create a new .mk file for ssmtp. The source is available on the debian servers and it does compile fine on the wl500g premium router natively and it works. There is documentation that shows how to make it work and I did verify this by sending an email to my gmail account from another gmail account. ssmtp is a relay server that was, at one point, going to replace sendmail for basic functions. Alas it doesn't seem to work with php and there is no wrapper for it yet.
    Last edited by shinji257; 19-06-2008 at 05:55.

  11. #11
    Join Date
    Dec 2007
    Location
    The Netherlands - Eindhoven
    Posts
    1,767
    I've updated my second post about compiling.
    these are things I found out that might come handy when compiling your own program
    I hope I didn't make any mistakes in them

  12. #12
    I would like to cross-compile this application for my Asus RT-N16. I would like to compile it under Ubuntu 9.

    First question I have - may I use tool chain used for wl500g?

    I've downloaded sources to /tmp/harimini. Sources come with 2 files - Makefile and build-arm.sh. First one has the following text:
    Code:
    # export CROSS=/stuff/tmp/work/armv4t-angstrom-linux-gnueabi/gcc-cross-4.2.4-r5/staging-pkg/cross/bin/arm-angstrom-linux-gnueabi-
    # export CPPFLAGS=-I/stuff/tmp/staging/armv4t-angstrom-linux-gnueabi/usr/include/mysql/
    # export CPPFLAGS=-I/usr/include/libxml2/
    export CPPFLAGS=-DUSE_MYSQL_WRAPPER -I/usr/include/libxml2/ -I/usr/include/mysql
    # export CPPFLAGS=-DUSE_MYSQL_WRAPPER -I/stuff/tmp/work/armv4t-angstrom-linux-gnueabi/libxml2-2.7.2-r0/staging-pkg/staging/armv4t-angstrom-linux-gnueabi/usr/include/libxml2
    # export CXXFLAGS=-msoft-float -D__GCC_FLOAT_NOT_NEEDED -march=armv4 -mtune=arm920t -Wcast-align
    # export CFLAGS=-msoft-float -D__GCC_FLOAT_NOT_NEEDED -march=armv4 -mtune=arm920t -Wcast-align 
    # export LDFLAGS=-L/stuff/tmp/staging/armv4t-angstrom-linux-gnueabi/usr/lib/mysql/
    # export CC=${CROSS}gcc ${CFLAGS}
    #export LD=${CROSS}ld
    # export CXX=${CROSS}g++ ${CXXFLAGS}
    
    LIBRARIES=RA SerializeClass PlutoUtils DCE pluto_main lmce_datalog
    APPS=DCERouter MessageSend sqlCVS mysql_wrapper CreateDevice
    DCEDEVS=ZWave AEt_EMC2000 Tongdy_RS485 # EnOcean_TCM120 
    PLUGINS=RPC_Plugin Lighting_Plugin DataLogger_Plugin
    CONFLICTING=
    
    all: libs nolibs
    
    nolibs: plugins apps
    
    apps: required_dirs dcedevs intersecting
    	for i in $(APPS); do $(MAKE) -C $$i || exit $$?; done
    
    dcedevs: required_dirs
    	for i in $(DCEDEVS); do $(MAKE) -C $$i bin || exit $$?; done
    
    libs: required_dirs
    	for i in $(LIBRARIES); do $(MAKE) -C $$i || exit $$?; done
    
    plugins: required_dirs
    	for i in $(PLUGINS); do $(MAKE) -C $$i so || exit $$?; done
    
    intersecting: required_dirs
    	for i in $(CONFLICTING); do $(MAKE) -C $$i clean all || exit $$?; done
    
    required_dirs:
    	mkdir -p bin lib 2>/dev/null
    
    # you have to request yourself; there's no target depending on it
    packages: all
    	@echo "** Expect lots of editing to do :) Press enter to start"
    	read
    	for i in $(APPS) $(DCEDEVS) $(PLUGINS) $(CONFLICTING); do $(MAKE) -C $$i package; done
    
    clean:
    	@#for i in $(STANDALONE) $(PLUGINS) $(CONFLICTING); do $(MAKE) -C $$i clean || exit $$?; done
    	for i in '*.d' '*.d.*' '*.o'; do find -type f -name "$$i" -exec rm '{}' ';' ; done
    
    .PHONY: clean all
    and the second one:
    Code:
    #!/bin/bash
    # make clean
    CROSS=/stuff/tmp/work/armv4t-angstrom-linux-gnueabi/gcc-cross-4.2.4-r5/staging-pkg/cross/bin/arm-angstrom-linux-gnueabi- CPPFLAGS=-I/stuff/tmp/staging/armv4t-angstrom-linux-gnueabi/usr/include/mysql/ CXXFLAGS="-msoft-float -D__GCC_FLOAT_NOT_NEEDED -march=armv4 -mtune=arm920t" make
    Sources are without configure file.

    What should I change and where to compile this for rt-n16?

    Also, according to that software developer toolchain should include headers/libs for mysql, libattr and libxml2. Where can I take it?
    Asus RT-N16 1.9.2.7-rtn-r4051 | Asus O!Play Air 1.09P | Synology DS210j - 2xWD20EADS

Similar Threads

  1. [How to] rtorrent & ntorrent
    By mancub in forum WL-500gP Tutorials
    Replies: 101
    Last Post: 18-12-2008, 08:21
  2. [HOW TO] Bluetooth in wl500g
    By TIk in forum WL-500g/WL-500gx Tutorials
    Replies: 1
    Last Post: 17-09-2008, 22:38
  3. How-to: Use your router as a BitTorrent Client
    By GerardNL in forum WL-700g Tutorials
    Replies: 28
    Last Post: 24-10-2007, 20:38
  4. Replies: 0
    Last Post: 24-01-2007, 03:54
  5. Completely new WL700gE router crashed after firmware update - plz help!
    By ClaudeX in forum WL-700g Firmware Discussion
    Replies: 4
    Last Post: 20-07-2006, 01:03

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •