compile own programs

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Author Message
lem
DD-WRT Novice


Joined: 24 Aug 2006
Posts: 4

PostPosted: Mon Aug 28, 2006 15:59    Post subject: compile own programs Reply with quote
hi,

i'd like to compile a small ansi c program for dd-wrt. i think it's not possible to compile directly on the router. what is to do for cross compiling this?

rg
martin
Sponsor
GrumpY54gsv4
DD-WRT User


Joined: 07 Jun 2006
Posts: 286

PostPosted: Mon Aug 28, 2006 16:42    Post subject: Reply with quote
http://www.dd-wrt.com/dd-wrtv2/down.php?path=downloads%2Fsourcecode%2F&download=toolchains.x86.debian.sp1.tar.bz2
_________________
- WRT54gs v4 @ 225 Mhz - DD-WRT V24 vpn -
- SD/MMC Mod 128 MB - Serial port & JTAG -
- Diversity switch removed -




Joined: 01 Jan 1970
Posts:

PostPosted: Mon Aug 28, 2006 17:43    Post subject: Reply with quote
Ok. Here is a simple helloword example:

1. The helloworld.c source
Code:
#include <stdio.h>

int main ( void ) {
        printf( "Hello world!\n" );
}


2. Get and unpack the toolchain in your homedir
Code:
cd ~
wget ftp://ftp.dd-wrt.com/sourcecode/toolchains.x86.debian.sp1.tar.bz2
tar -jxf toolchains.x86.debian.sp1.tar.bz2


3. Add the path to your cross-compiler executable to your path environment variable and compile helloworld.c
Code:
PATH=~/toolchains/4.1.0-uclibc-0.9.28/bin:$PATH mipsel-linux-uclibc-gcc helloworld.c -o helloworld


4. Check if its correctly compiled with the cross-compiler
Code:
file helloworld
helloworld: ELF 32-bit LSB executable, MIPS, version 1 (SYSV), dynamically linked (uses shared libs), not stripped


5. Finally, transfer the helloworld binary file to your router, set the executable bit and run it.

Tested with Ubuntu 6.06.1 LTS.



To build DD-WRT from source see The DD-WRT v23 SP1 Final building guide.
montesq
DD-WRT Novice


Joined: 21 Oct 2006
Posts: 3

PostPosted: Sat Nov 04, 2006 15:11    Post subject: Reply with quote
Code:
PATH=~/toolchains/4.1.0-uclibc-0.9.28/bin:$PATH mipsel-linux-uclibc-gcc helloworld.c -o helloworld

Ok that's good to compile a simple file!
But in the case where I need compile a more complex project!
Normally (with linux) you make :
Code:

./configure
make


Where do I indicate that is a cross compilation? Where do I specify the executable is not for my pc but for the router?

Thanx for any answer...




Joined: 01 Jan 1970
Posts:

PostPosted: Sat Nov 04, 2006 15:36    Post subject: Reply with quote
DD-WRT sucks. Why? See http://www.bitsum.com/about-ddwrt.htm

Last edited by on Tue Nov 28, 2006 15:55; edited 2 times in total
montesq
DD-WRT Novice


Joined: 21 Oct 2006
Posts: 3

PostPosted: Sat Nov 04, 2006 15:50    Post subject: Reply with quote
forum2006 wrote:
montesq, I'd recommend you take look at OpenWrt's buildroot and X-Wrt's webif^2. DD-WRT's build system is horrible and a piece of crap.

Go and test OpenWrt, perheps you like it. With OpenWrt's buildroot crosscompilation is very easy. F.e. if you like to build your own OpenWrt images you just have to check out svn branch and run:

Code:
make menuconfig
make


Takes about an hour or so and you have ready to use images in the bin/ folder.


I've already "played" with openwrt, and it's true that compiling kernel sources is easier but that's not my problem!!
I only want to compile an application (e.g. openssh) and add it in the firmware of dd-wrt, it's why I need know how to cross-compile with the procedure : ./configure & make ...




Joined: 01 Jan 1970
Posts:

PostPosted: Sat Nov 04, 2006 15:52    Post subject: Reply with quote
DD-WRT sucks. Why? See http://www.bitsum.com/about-ddwrt.htm

Last edited by on Tue Nov 28, 2006 15:55; edited 1 time in total
DiablodeMorte
DD-WRT Novice


Joined: 29 Jul 2006
Posts: 8

PostPosted: Tue Nov 21, 2006 0:35    Post subject: Reply with quote
Anybody want to humor me and help me? I want to compile a script I have for GCC on the DDWRT. it's a tutorial script as I am pretty dang new to the Linux comunity. Anyway. I didn't understand the post a couple of posts above and would like to know what I need to do to get the script working on the DD-WRT. I tried compiling in under normal GCC and it simply won't run on my router. What do I need to do? I would really appreciate SIMPLE instructions. Right now I have GCC installed(On my linux box) and the toolchain that was in the link downloaded(To my linux box)

My Linux Box is running CentOS 4.2

Thanks in Advance

P.S. Oh yea. the script: http://sage.mc.yu.edu/kbeen/teaching/networking/resources/tcp-server.cc
Martijn_Donath
DD-WRT Novice


Joined: 30 Aug 2008
Posts: 1

PostPosted: Sat Aug 30, 2008 8:45    Post subject: It's not difficult... Reply with quote
The procedure as described by 'sagichnict04' worked for me with a few corrections:

step 2: The toolchain is located at: ftp://ftp.dd-wrt.com/others/sourcecode/toolchains/

The toolchain is used to make a binary which runs on your router. This is necessary due to different processor architectures.

When using a Makefile, look for an option called 'CROSS':
CROSS = mipsel-linux-uclibc-

Then run 'make'.

Tested with Mandriva Spring 2008.1 Free.

I used it to compile a newer version of p910nd (0.92) because ipkg has version 0.7.
ggp81
DD-WRT Novice


Joined: 07 Feb 2007
Posts: 45

PostPosted: Tue Jun 23, 2009 8:59    Post subject: Reply with quote
I have successfully compiled and tried DD-WRT from trunks.
Now I would like to make some modifications, for example adding some files, for example in the /etc directory.
How to do that?

I have tried to add an "hello world" file directly to src/router/mipsel-uclibc/target directory, but the image created didn't work.
I also have tried to add it to src/router/misc directory, but looks like that directory is not taken in consideration during the building process.

Any suggestion is appreciated.
Thank you.
furang
DD-WRT Novice


Joined: 18 Oct 2010
Posts: 6

PostPosted: Wed Nov 03, 2010 9:48    Post subject: Reply with quote
Guys this toolchain is for x86-64 machines. And how should I compile on simple x86 i386 machine?
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum