OpenWrt Forum Archive

Topic: Cross compiling problem

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

Hi all

To do cross compiling I am following this instruction : https://wiki.openwrt.org/doc/devel/crosscompile
In the 5th task they mentioned "Download and unpack the code to be compiled, change into the unpacked directory"
Is it means that I have to locate the downloaded code inside the openwrt build root directory ? or ?

why does it necessary to set the path variable?

I can not understand that where should I put the downloaded code to be compile. Inside the openwrt build root directory there is a file name "Makefile"  and my downloaded source directory has a file named "Makefile" . Should I patch them for compiling??

Thanks.

You have to locate your code inside ~/OpenWrt-SDK/feeds/packages/utils.
There you create a directory and inside it, the "exterior" Makefile and inside another directory created by you called src, you have to put the "interior" Makefile which will compile your C code, and obviously, your C code.

adnan wrote:

Is it means that I have to locate the downloaded code inside the openwrt build root directory ? or ?

No, you do not need to unpack the source code of your new program into the OpenWRT build directory. You can unpack it wherever you want to. In fact, it is recommended to unpack the sourcecode outside of the build directory.

adnan wrote:

why does it necessary to set the path variable?

The path variable ensures that commands such as 'cc' that the external source's makefile invokes get directed to the cross-compilation tools that are built as part of the OpenWRT Buildroot's build process. These tools are capable of building binary images that can run on the target system. This is the essence of what cross-compilation does.

adnan wrote:

I can not understand that where should I put the downloaded code to be compile. Inside the openwrt build root directory there is a file name "Makefile"  and my downloaded source directory has a file named "Makefile" . Should I patch them for compiling??

I recommend you unpack your new program's source code somewhere else, say, '/home/user/myshinyprogram/'

It is possible to integrate your external program to be a part of the OWRT build process, so that it gets compiled and placed to the root filesystem image that you can then flash to your router. This is known as adding a new package into the OWRT.

But I recommend you do not attempt this yet. Creating a new package is not necessary in order to test your program, and it is quite difficult to do unless you know the ins and outs of the OWRT build system.

Thanks

It is working.

The discussion might have continued from here.