Building OpenWrt

How does someone find out the requirements to compile a build? Where is this information available for viewing?

In the wiki:
https://openwrt.org/docs/guide-developer/build-system/start

1 Like

It seems as if it's some trial and error involved?

Unfortunately not all dependencies are checked by make config , especially for packages. You may encounter compile errors because you need a specific library in your system, and the only way is to search the missing library from the compiler error log and see what package contains it in your own distro.

Is there a concise way of looking up this information? I'm confused as to why each Linux version has different requirements to build the same way? I understand some have preinstalled packages and what not but it seems counterintuitive to have so many scenarios to compile the same source code such as e.x. v19.07.4

I've been able to compile thus far by installed the suggested base packages and then running a make prereq, observing what's missing, installing that, rinse and repeat. It doesn't seem correct or am I wrong? I'm not a developer, and I'm learning by trial and error which seems to be mostly error walking in the dark.

v19.07.4 won't compile no matter what and it just stops producing a difference error each time. I've tried just making the default build whereas previously I didnt't have any problems (again me learning by reading the lacking documentation and trial by fire).


is more or less accurate. However, in case you detect a problem during build, you might consider to do "make dirclean", before doing next try. Sometimes some "dirt" is not recovered on next build, otherwise.
As usual for Open Source, the only correct doc is the soure code.
1 Like
 git clone https://git.openwrt.org/openwrt/openwrt.git

        cd openwrt

        ./scripts/feeds update -a && ./scripts/feeds install -a

        # git fetch --tags && git tag -l && git checkout v19.07.4

        wget https://downloads.openwrt.org/releases/19.07.4/targets/ath79/generic/config.buildinfo -O .config

        # make menuconfig # select target/subtarget

        make -j4 defconfig # expand the config and the defaults

        ./scripts/diffconfig.sh > diffconfig # write the changes to diffconfig

        # Using diff file
        # These changes can form the basis of a config file (<buildroot dir>/.config). By running make defconfig these changes will be expanded into a full config.

        # cp diffconfig .config   # write changes to .config
        # make defconfig   # expand to full config
        # These changes can also be added to the bottom of the config file (<buildroot dir>/.config), by running make defconfig these changes will override the existing configuration.

        # cat diffconfig >> .config   # append changes to bottom of .config
        # make defconfig   # apply changes

        make -j4 kernel_menuconfig CONFIG_TARGET=subtarget

        make -j4 download

        make -j4 V=99

I've also tried without and -j$ options. I'm lost :thinking:

You need to analyze the output, i.e. fix errors if any.

git clone https://git.openwrt.org/openwrt/openwrt.git
cd openwrt
git checkout -b v19.07.4
make distclean
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig

Should "make distclean" be run even when compiling a fresh build?

you need that when you switch from master to 19.07 .4
after you have cloned the repository, do not do ./scripts/feeds update and install all.
do the line i posted in order.

Wrong order. First select branch or tag, and then update feeds.

  1. git clone https://git.openwrt.org/openwrt/openwrt.git
  2. cd openwrt
  3. git fetch --tags && git tag -l && git checkout v19.07.4
    (if you really want the static old 19.07.4 instead of the current HEAD of the 19.07 branch)
  4. ./scripts/feeds update -a && ./scripts/feeds install -a

Then finally select target / device etc. and do defconfig (or makeconfig) before the build

Ps.
there is not much point in wget https://downloads.openwrt.org/releases/19.07.4/targets/ath79/generic/config.buildinfo -O .config.
The release builds are made with just the defaults for each device + LuCI GUI.

Pps.
And if you are just learning the build system basics, there is no point in looking at kernel_menuconfig

2 Likes

Can I still use the official repo without the config.buildinfo?

sure.
the release config really just is the default packages for the device + LuCI GUI.
You can just start with empty .config and use "make menuconfig" to select a device (and luci, if you want GUI), and you are good to go.

I appreciate all the help! I'll try again today when I get home from work.

And do you know how to force a kernel hash for a build?

I would like to know how to backport a device from snapshot to 19.07.4 and use release packages, but never found info about it

Br,
Valentín :slight_smile:

You'd need to git check out the release tag, and use the same config file as used for the release build (they're provided alongside).

I think the kernel hash is unique for each build session. That's the reason of my question

It's calculated based on the kernel options enabled. That's why re-using the original configuration should give you the same hash.

Edit: @vk496 - this should be your git commit to check out:


$ git show-ref -s v19.07.4
85c1a751354c8d373db38675437a2ec5fa1034a4

Not sure for the matching packages tag, but it's a separate tree maintained on GitHub.

1 Like