Cross-compile from Ubuntu

Hello, I need to compile a simple custom C program (linked with libusb) for my router (MIPS 24kc, ar71xx target) from an Ubuntu machine. Do I need a special GCC toolchain or the standard GCC will do (then what compiler options to use)?

Also I guess I'll have to link it against the libc library version used on the router, so what is the right way of doing it? Or maybe there is a wiki page describing how to set up a development environment for cross-compiling for the ar71xx target which I haven't found?

Thank you.

You need a LEDE toolchain with tailored gcc and necessary libraries etc. so that you get the compilation options just right.

Either install the full build environment or use the SDK that enables compiling just single packages.

https://lede-project.org/docs/guide-developer/install-buildsystem
https://lede-project.org/docs/guide-developer/use-buildsystem

https://lede-project.org/docs/guide-developer/compile_packages_for_lede_with_the_sdk

But I think that you need to form a real "package" out of your file, especially as you want libusb.

You might also read these old examples
(query: https://www.google.com/search?q=openwrt+sdk+single+c+file )

https://www.gargoyle-router.com/old-openwrt-coding.html
https://forum.openwrt.org/viewtopic.php?id=44846

1 Like

Thanks, this seems to be exactly what I needed!