OpenWrt Forum Archive

Topic: Compiling "helloworld" vor Kamikaze 7.09

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

Hi folks,

I just want to compile some source for my Kamikaze 7.09 device. Therefore I get the SDK (OpenWrt-SDK-brcm-2.4-for-Linux-x86_64.tar.bz2). I put my helloworld.c in the "packages" dir and run a "make V=99", but I can't get it running.

My helloworld.c looks like this:

#include <stdio.h>

int main(void)
{
    printf("Hello world");
    return 0;
}

Locally (VMPlayer Debian Etch 4.01) it just runs fine. Unfortunatelly I couldn't get any help out of the Wiki or other topics here.

Can somebody explain me, how to compile this script for my devide? Would be very nice.

Nobody can help me?

After reading your post and http://wiki.openwrt.org/BuildingPackagesHowTo I decided to test native development and...
---
[root@xdev tmp]# uname -a
Linux xdev 2.4.34 #18 Mon Nov 26 17:48:54 CST 2007 mips unknown unknown GNU/Linux
---
First...
[root@xdev tmp]# gcc -o helo hello.c
[root@xdev tmp]# ls -l ./hello
-rwx------  1 root root 68963 Dec 29 14:16 ./hello*---
[root@xdev tmp]# ./hello
Hello world[root@xdev tmp]#
---
Let's try c++
[root@xdev tmp]# g++ -o hello hello.c
[root@xdev tmp]# ls -l ./hello
-rwx------  1 root root 68963 Dec 29 14:11 ./hello*
[root@xdev tmp]# ./hello
Hello world[root@xdev tmp]#

johnpatcher wrote:

I just want to compile some source for my Kamikaze 7.09 device. Therefore I get the SDK (OpenWrt-SDK-brcm-2.4-for-Linux-x86_64.tar.bz2). I put my helloworld.c in the "packages" dir and run a "make V=99", but I can't get it running.

If you want to do it that way, then you need to create package/foo/Makefile. Start with another package and modify that; I'd suggest you copy package/nvram which is an example where its source files are directly included in a src/ directory, rather than a downloaded tarball.

But more simply you can compile your helloworld.c just by invoking the appropriate cross-compiler directly:

staging_dir_i386/bin/i386-linux-uclibc-gcc -o helloworld helloworld.c

The above example is with Kamikaze 7.09 for x86. Adjust the path and filename for other targets. If you're using subversion trunk then it will be

staging_dir/toolchain-i386_gcc4.1.2/bin/i386-linux-uclibc-gcc -o helloworld helloworld.c

The discussion might have continued from here.