Compiling simple c program in openwrt

I am tying to get a c file to compile on my Netgear wndr3700v5, i already have openwrt installed and running but anfer opkg update i can't install anything, gcc, git, make, ecc.. because of my "configured architectures" when i list the architectures with opkg 3 arch pop up i am very very new. Any help is very apricieted.

I arledy tried to follow the helloworld guide and the sdk installation but no succes

The build system is generally supposed to be run on a normal computer -- typically a linux box or a linux VM, but WSL and Mac OS can be used, too.

Although it is possible to build on OpenWrt itself, it's not generally recommended. There is no possible way you could fit the sdk on any normal consumer all-in-one router, and even if you had enough space, it would be extraordinarly slow on a consumer router. You've got 16 MB of storage on your device, and you need at least 26 GB of storage for the build system to work (that's only about 1600x more than what you have in the entire router, not counting the running firmware that is installed now taking up part of that space).

Please see the "Using the toolchain" section of the developer user guide page (and click into the links relating to the system(s) you have available):

I hope you didn't use the opkg upgrade command... update is fine, upgrade is not.

Upgrading packages (via the CLI opkg upgrade command or the LuCI Upgrade... button) can result in major problems. It is generally highly discouraged, unless you know what you are doing or if there is specific instruction to do so.

2 Likes

You cannot compile on the box (not enough CPU power, not enough RAM, not enough memory ...), you need to cross compile on your host computer.

Following hello world and SDK is a good idea - where are you stuck at?

1 Like

Thanks everyone for the quick response. I am stuck at the part of installing all the tool and libraries, i have a question: if plug a usb drive in the usb port would i be able to complile or as u said still bot enough juice?

And if i can't compile c, because i am trying to make a pure fun project with the router i had lying around and gad couple of ideas:

  • c and cpp
  • python o js hosting
  • web server
  • home assistant from flashdrive

Can u tell witch one of thees would work?

Yes i used only the update command

Did you read the system requirements for building OpenWrt on OpenWrt?

1GHz or faster CPU, multi-core is an asset.
512MiB of physical RAM per core you intend to use in the build for 32-bit devices. For 64-bit devices you need double this.1
2GiB of swap space. This should be on a physical hard drive, or a high quality external device (meaning not the device's internal eMMC).2
1GiB of storage space on your root device for all the OpenWrt packages you will need.
~26GiB of storage space for the build

Your device has:

  • single core 880 MHz MediaTek CPU
  • 16 MB flash storage
  • 128 MB RAM.

So no, it is not possible to run the toolchain on your device, even with a large external flash drive.

OpenWrt is not self-hosting, you don't build on the device, you build for the device by the means of a cross-compiler (provided to you in the form of either the SDK or the full source buildroot).

get a free VM at Google, Amazon, Microsoft or Oracle.

run your compiling there.

Ok, i arleady a laptop for compiling but is there anyway i can use it as a web server or for python just for fun

Thanks for the response, i am not gonna use it for hosting it is just for fun nothing else

Never mind just for fun, you can do some serious development work on this router using PHP.
You can run php code both with the standard uhttpd web server and on the command line.
You will find it runs fast and efficiently with plenty of headroom....

thanks!!
how about compiling cgi from cpp with make?

Not on the router as explained by the others. You will still have to cross compile.
When a web server runs cgi code it is simply running an executable of some sort.
The php-cgi package is an executable that interprets php scripts and passes the output of the scripts to the web server. So no compiling needed.
You can use this approach to code up some very sophisticated interactive web pages.

Ok thanks a lot