User Tools

Site Tools


doc:howto:build

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doc:howto:build [2014/03/05 22:21]
guraltsev swapped position of two paragraphs that were in the wrong order
doc:howto:build [2014/10/20 12:16] (current)
bastian.bittorf explain what 'clean' does not, see https://dev.openwrt.org/ticket/18171#comment:1
Line 9: Line 9:
     * ''​SED''​ should not be set.  If it is, run ''​`unset SED`''​ before compiling. (See [[https://​dev.openwrt.org/​ticket/​10612|Ticket 10612]].)     * ''​SED''​ should not be set.  If it is, run ''​`unset SED`''​ before compiling. (See [[https://​dev.openwrt.org/​ticket/​10612|Ticket 10612]].)
     * ''​GREP_OPTIONS''​ should not have ''​--initial-tab''​ or other options affecting its output     * ''​GREP_OPTIONS''​ should not have ''​--initial-tab''​ or other options affecting its output
 +    * Add ''<​buildroot dir>/​staging_dir/​host/​bin''​ and ''<​buildroot dir>/​staging_dir/​toolchain-<​platform>​-<​gcc_ver>​-<​libc_ver>/​bin''​ in front of your ''​PATH''​ variable in ''​~/​.bashrc''​. The staging directory is created shortly after starting the build and the toolchain directory is created when the toolchain build begins. The build spawns multiple shells, some of which expect the toolchain binaries to be present in the ''​PATH''​.
  
 ===== Procedure ===== ===== Procedure =====
Line 22: Line 23:
  
 ==== Updating Sources ==== ==== Updating Sources ====
-You can check the currently installed revision with +You can perform a new check out of trunk with (for instance) 
-<WRAP prewrap 1000px><​code>​+<​code>​ 
 +svn co svn://​svn.openwrt.org/​openwrt/​trunk/​ trunk 
 +</​code>​ 
 + 
 +Instructions with Git repos can be found under https://​dev.openwrt.org/​wiki/​GetSource 
 + 
 +You can check out a currently installed revision with  
 +<​code>​
 svn info svn info
-</code></​WRAP>+</​code>​
  
  
 Update sources: Update sources:
-<WRAP prewrap 1000px><​code>​+<​code>​
 svn update svn update
-</code></​WRAP>+</​code>​
 //OpenWrt sources change frequently. It is recommended that you work with the latest sources.// //OpenWrt sources change frequently. It is recommended that you work with the latest sources.//
  
  
 ==== Updating Feeds ==== ==== Updating Feeds ====
-  - Update feeds: ​<WRAP prewrap 1000px><​code>​./​scripts/​feeds update -a</code></​WRAP>+  - Update feeds: <​code>​./​scripts/​feeds update -a</​code>​
   - Make downloaded package/​packages available in ''​make menuconfig'':​   - Make downloaded package/​packages available in ''​make menuconfig'':​
-    * single package:<WRAP prewrap 1000px><​code>​./​scripts/​feeds install <​PACKAGENAME></​code></​WRAP+    * single package:<​code>​./​scripts/​feeds install <​PACKAGENAME></​code>​ 
-    * all packages:<WRAP prewrap 1000px><​code>​./​scripts/​feeds install -a</code></​WRAP>+    * all packages:<​code>​./​scripts/​feeds install -a</​code>​
  
 Please note that //​installing//​ in context of ''​./​scripts/​feeds''​ script means "​making package available in ''​make menuconfig''"​ rather than really installing or compiling package. Please note that //​installing//​ in context of ''​./​scripts/​feeds''​ script means "​making package available in ''​make menuconfig''"​ rather than really installing or compiling package.
Line 46: Line 54:
 ==== Make menuconfig ==== ==== Make menuconfig ====
 The **OpenWrt Buildroot configuration interface** handles the selection of the target platform, packages to be compiled, packages to be included in the firmware file, some kernel options, etc. \\ Start the OpenWrt Buildroot configuration interface by issuing the following command:\\ The **OpenWrt Buildroot configuration interface** handles the selection of the target platform, packages to be compiled, packages to be included in the firmware file, some kernel options, etc. \\ Start the OpenWrt Buildroot configuration interface by issuing the following command:\\
-<WRAP prewrap 1000px><​code>​+<​code>​
 make menuconfig make menuconfig
-</code></​WRAP>+</​code>​
  
 This will update the dependencies of your existing configuration automatically,​ and you can now proceed to build your updated images. ​ This will update the dependencies of your existing configuration automatically,​ and you can now proceed to build your updated images. ​
Line 80: Line 88:
  
 While you won't typically need to do this, you can do it: While you won't typically need to do this, you can do it:
-<WRAP prewrap 1000px><​code>​+<​code>​
 make kernel_menuconfig make kernel_menuconfig
-</code></​WRAP>+</​code>​
 The changes can be reviewed with The changes can be reviewed with
-<WRAP prewrap 1000px><​code>​+<​code>​
 svn diff target/​linux/​ svn diff target/​linux/​
-</code></​WRAP>+</​code>​
 and reverted with  and reverted with 
-<WRAP prewrap 1000px><​code>​+<​code>​
 svn revert -R target/​linux/​ svn revert -R target/​linux/​
-</code></​WRAP>+</​code>​
  
  
Line 122: Line 130:
 ==== Defconfig ==== ==== Defconfig ====
 [[https://​forum.openwrt.org/​viewtopic.php?​pid=140470#​p140470|select your target before issuing defconfig]] [[https://​forum.openwrt.org/​viewtopic.php?​pid=140470#​p140470|select your target before issuing defconfig]]
-<WRAP prewrap 1000px><​code>​+<​code>​
 make defconfig make defconfig
-</code></​WRAP>+</​code>​
 will produce a general purpose configuration of the build system including a check of dependencies and prerequisites for the build environment etc will produce a general purpose configuration of the build system including a check of dependencies and prerequisites for the build environment etc
  
Line 132: Line 140:
 Everything is now ready for building the image(s), which is done with one single command: Everything is now ready for building the image(s), which is done with one single command:
  
-<WRAP prewrap 1000px><​code>​+<​code>​
 make make
-</code></​WRAP>+</​code>​
  
 This simple command will trigger a cascade of activity. As already stated, it will This simple command will trigger a cascade of activity. As already stated, it will
Line 144: Line 152:
 ==== Make options ==== ==== Make options ====
 === Building on multi-core CPU === === Building on multi-core CPU ===
-**Build may FAIL**+:!: **Build may FAIL**
  
 The build process can be accelerated by running multiple concurrent job processes using the ''​-j''​-option:​ The build process can be accelerated by running multiple concurrent job processes using the ''​-j''​-option:​
-<WRAP prewrap 1000px><​code>​+<​code>​
 make -j 3 make -j 3
-</code></​WRAP>+</​code>​
   * Use the standard formula ''<​your number of CPU cores + 1>''​   * Use the standard formula ''<​your number of CPU cores + 1>''​
   * If this produces random build errors try compiling again without the ''​-j''​-option   * If this produces random build errors try compiling again without the ''​-j''​-option
Line 156: Line 164:
 If you intend to use your system while building, you can have the build process use only idle I/O and CPU capacity like this (dualcore CPU): If you intend to use your system while building, you can have the build process use only idle I/O and CPU capacity like this (dualcore CPU):
  
-<WRAP prewrap 1000px><​code>​+<​code>​
 ionice -c 3 nice -n19 make -j 2 ionice -c 3 nice -n19 make -j 2
-</code></​WRAP>+</​code>​
  
 === Building single Packages === === Building single Packages ===
 When developing or packaging software for OpenWrt, it is convenient to be able to build only the package in question (e.g. with package ''​cups''​):​ When developing or packaging software for OpenWrt, it is convenient to be able to build only the package in question (e.g. with package ''​cups''​):​
  
-<WRAP prewrap 1000px><​code>​+<​code>​
 make package/​cups/​compile V=s make package/​cups/​compile V=s
-</​code>​</​WRAP>​ +</​code>​
- +
-For the package ''​mc (midnight commander)'',​ which is contained the feed //​packages//​ it looks like this: +
-<WRAP prewrap 1000px><​code>​ +
-make package/​feeds/​packages/​mc/​compile V=s +
-</​code></​WRAP>​ +
- +
-//Note that the path start in ''​package''​ directory and ''​package/​feeds''​ may not have exactly the same structure as ''​feeds''​. For example package in ''​~/​openwrt/​trunk/​feeds/​packages/​**net**/​snort''​ will be compiled using ''​make ~/​openwrt/​trunk/​**package**/​feeds/​packages/​snort/​**compile** V=s''​.//​+
  
 +For a rebuild:
 +<​code>​
 +make package/​cups/​{clean,​compile,​install} V=s
 +</​code>​
  
 +It doesn'​t matter what feed the package is located in, this same syntax works for any installed package.
  
 === Spotting build errors === === Spotting build errors ===
 If for some reason the build fails, the easiest way to spot the error is to do: If for some reason the build fails, the easiest way to spot the error is to do:
  
-<WRAP prewrap 1000px><​code>​+<​code>​
 make V=s 2>&1 | tee build.log | grep -i error make V=s 2>&1 | tee build.log | grep -i error
-</code></​WRAP>+</​code>​
  
 The above saves a full verbose copy of the build output (with stdout piped to stderr) in ''/​openwrt/​trunk/​build.log''​ and only shows errors on the screen. The above saves a full verbose copy of the build output (with stdout piped to stderr) in ''/​openwrt/​trunk/​build.log''​ and only shows errors on the screen.
Line 187: Line 193:
 Another example: Another example:
  
-<WRAP prewrap 1000px><​code>​+<​code>​
 ionice -c 3 nice -n 20 make -j 2 V=s CONFIG_DEBUG_SECTION_MISMATCH=y 2>&1 | tee build.log | egrep -i '​(warn|error)'​ ionice -c 3 nice -n 20 make -j 2 V=s CONFIG_DEBUG_SECTION_MISMATCH=y 2>&1 | tee build.log | egrep -i '​(warn|error)'​
-</code></​WRAP>+</​code>​
  
 The above saves a full verbose copy of the build output (with stdout piped to stderr) in build.log and outputs only warnings and errors while building using only background resources on a dual core CPU. The above saves a full verbose copy of the build output (with stdout piped to stderr) in build.log and outputs only warnings and errors while building using only background resources on a dual core CPU.
Line 199: Line 205:
 Depending on your CPU, the process will take a while, or while longer. If you want an acoustic notification,​ you could use ''​echo -e '​\a''':​ Depending on your CPU, the process will take a while, or while longer. If you want an acoustic notification,​ you could use ''​echo -e '​\a''':​
  
-<WRAP prewrap 1000px><​code>​+<​code>​
 make V=s ; echo -e '​\a'​ make V=s ; echo -e '​\a'​
-</code></​WRAP>+</​code>​
  
 ===== Locating Images ===== ===== Locating Images =====
Line 212: Line 218:
  
 ==== Clean ==== ==== Clean ====
-<WRAP prewrap 1000px><​code>​+<​code>​
 make clean make clean
-</code></​WRAP>+</​code>​
  
 deletes contents of the directories ''/​bin''​ and ''/​build_dir''​. deletes contents of the directories ''/​bin''​ and ''/​build_dir''​.
 +make clean does not remove the toolchain,​ 
 +it also avoids cleaning architectures/​targets other than the one you have selected in your ''​.config''​
  
 ==== Dirclean ==== ==== Dirclean ====
-<WRAP prewrap 1000px><​code>​+<​code>​
 make dirclean make dirclean
-</code></​WRAP>+</​code>​
  
 deletes contents of the directories ''/​bin''​ and ''/​build_dir''​ and additionally ''/​staging_dir''​ and ''/​toolchain''​ (=the cross-compile tools) and ''/​logs''​. '​Dirclean'​ is your basic "Full clean" operation. deletes contents of the directories ''/​bin''​ and ''/​build_dir''​ and additionally ''/​staging_dir''​ and ''/​toolchain''​ (=the cross-compile tools) and ''/​logs''​. '​Dirclean'​ is your basic "Full clean" operation.
Line 228: Line 235:
  
 ==== Distclean ==== ==== Distclean ====
-<WRAP prewrap 1000px><​code>​+<​code>​
 make distclean make distclean
-</code></​WRAP>+</​code>​
  
 nukes everything you have compiled or configured and also deletes all downloaded feeds contents and package sources. nukes everything you have compiled or configured and also deletes all downloaded feeds contents and package sources.
Line 243: Line 250:
  
 Clean linux objects. Clean linux objects.
-<WRAP prewrap 1000px><​code>​+<​code>​
 make target/​linux/​clean make target/​linux/​clean
-</code></​WRAP>+</​code>​
  
 Clean package base-files objects. Clean package base-files objects.
-<WRAP prewrap 1000px><​code>​+<​code>​
 make package/​base-files/​clean make package/​base-files/​clean
-</code></​WRAP>+</​code>​
  
 Clean luci. Clean luci.
-<WRAP prewrap 1000px><​code>​ +<​code>​ 
-make package/feeds/luci/​luci/​clean +make package/​luci/​clean 
-</code></​WRAP>+</​code>​
  
 ===== Examples ===== ===== Examples =====
Line 264: Line 271:
 ===== Troubleshooting ===== ===== Troubleshooting =====
 First get more information on the problem using the make option ''"​make V=s"''​. First get more information on the problem using the make option ''"​make V=s"''​.
 +
 +
 +==== Errors building gcc ====
 +If the build fails with errors that include "​[s-attrib] Killed"​ and "​[all-gcc] Error 2" while compiling gcc, this indicates you are out of disk space or RAM. This could be likely if you are building within a virtual machine with < 1 Gb RAM allocated and no swap.
  
 ==== Missing source code file, due to download problems ==== ==== Missing source code file, due to download problems ====
Line 275: Line 286:
 Compiling with make -j ... sometimes gives random errors. Try compiling without -j first before reporting the problem. Compiling with make -j ... sometimes gives random errors. Try compiling without -j first before reporting the problem.
  
-====  Bad environment variables ==== +
-  * ''​GREP_OPTIONS''​ should not have ''​--initial-tab''​ or other options affecting its output +
-  * **''​SED''​ should not be set.  If it is, run `unset SED` before compiling.** (See [[https://​dev.openwrt.org/​ticket/​10612|Ticket 10612]].) +
-  * others?+
  
 ==== I can't find my <​package>​ in menuconfig ==== ==== I can't find my <​package>​ in menuconfig ====
-  - Have you run this command? [[doc:​howto:​build#​updating.feeds|See this.]] ​<WRAP prewrap 1000px><​code>​./​scripts/​feeds install <​package></​code></​WRAP+  - Have you run this command? [[doc:​howto:​build#​updating.feeds|See this.]] <​code>​./​scripts/​feeds install <​package></​code>​ 
-  - Maybe you are not looking for it in the right submenu. See the ''​Makefile''​ of the package to find out. <WRAP prewrap 1000px><​code>​cat ​package/feeds/packages/<​package>/​Makefile</​code></​WRAP> You are looking for this: \\ ''​define Package/<​package>/​Default+  - Maybe you are not looking for it in the right submenu. See the ''​Makefile''​ of the package to find out. <​code>​cat feeds/<​feedname>​/<​package>/​Makefile</​code>​ You are looking for this: \\ ''​define Package/<​package>/​Default
   SUBMENU:​=**Firewall**   SUBMENU:​=**Firewall**
   SECTION:​=net   SECTION:​=net
   CATEGORY:​=**Network**''​   CATEGORY:​=**Network**''​
-  - Menuconfig appears to cache package lists and (especially) profiles. Try deleting the ''<​buildroot_dir>/​tmp''​ directory and then running ''​make menuconfig''​ again. ​<WRAP prewrap 1000px><​code>​+  - Menuconfig appears to cache package lists and (especially) profiles. Try deleting the ''<​buildroot_dir>/​tmp''​ directory and then running ''​make menuconfig''​ again. <​code>​
 cd ~/​openwrt/​trunk cd ~/​openwrt/​trunk
 rm -rf tmp rm -rf tmp
-make menuconfig</​code></​WRAP> Also try refreshing your package indexes: ​<WRAP prewrap 1000px><​code>​./​scripts/​feeds update -i</code></​WRAP> The ''​-i''​ is important if you're not using the latest revisions of any packages, as this flag prevents updates from the feed sources. +make menuconfig</​code>​ Also try refreshing your package indexes: <​code>​./​scripts/​feeds update -i</​code>​ The ''​-i''​ is important if you're not using the latest revisions of any packages, as this flag prevents updates from the feed sources.
- +
-====  Error: No rule to make target... ==== +
-Make sure the path starts with ''​package''​ directory and that the path actually exist. The structure of ''​feeds''​ and ''​package/​feeds''​ directory is different. [[doc:​howto:​build#​building.single.packages|See this.]] +
-  * Wrong: ''​make feeds/​packages/​**utils**/​screen/​compile V=s''​ +
-  * Correct: ''​make **package**/​feeds/​packages/​screen/​compile V=s''​+
  
 ==== WARNING: skipping <​package>​ -- package not selected ==== ==== WARNING: skipping <​package>​ -- package not selected ====
doc/howto/build.1394054506.txt.bz2 · Last modified: 2014/03/05 22:21 by guraltsev