README.compile-and-pre-built-binaries 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. Compilation and pre-built binaries FAQ
  2. ======================================
  3. What is the best pre-built binary for my system or device?
  4. ----------------------------------------------------------
  5. None. The best binary is compiled by yourself using a toolchain that is
  6. optimized for your system or device in every respect.
  7. How do I compile my own binary?
  8. -------------------------------
  9. On a full blown desktop system this is relativly easy. If not already done so,
  10. install a C compiler (e.g. gcc or clang) through your packet manager, e.g.
  11. "sudo apt-get install gcc" (Debian/Ubuntu) or "sudo yum install gcc"
  12. (RedHat/Fedora).
  13. Then cd to your vlmcsd directory and type "make". vlmcs and vlmcsd will
  14. be built right away for your local system.
  15. If you installed gcc and it is not the default compiler for your OS or
  16. distribution, you may need to type "make CC=gcc" to explicitly select a
  17. specific C compiller.
  18. How do I compile a binary for my embedded device?
  19. -------------------------------------------------
  20. What you need is cross-compiling toolchain for your device. It consists of a
  21. C compiler, libraries, header files and some tools (called binutils). The
  22. toolchain must match the device in processor architecture, endianess, ABI,
  23. library and header files version, library configuration, ...
  24. If the endianess or ABI differs or the version of some library between
  25. toolchain and device differs too much, the resulting binary does not run
  26. on your device.
  27. Once you have a proper toolchain (probably found on the Internet for download),
  28. unpack it to any directory and type
  29. "make CC=/path/to/toolchain/bindir/c-compiler-binary"
  30. Building vlmcsd for using a cross-compiling toolchain is as easy as building
  31. vlmcsd for your local machine. The only question is, whether this you have
  32. a toolchain that actually matches your device.
  33. Whenever you change any parameter of the make command line, you must "clean"
  34. the source directory from intermediate files and output from previous runs
  35. of make. You can do so by typeing "make clean" or force make to behave as if
  36. the directory were clean by adding -B to the command line, e.g.
  37. "make -B CC=/path/to/toolchain/bindir/c-compiler-binary"
  38. I have downloaded several promising toolchains for my device but they all
  39. don't work. Can I create my own toolchain?
  40. -------------------------------------------------------------------------
  41. You can use tools like buildroot or OpenWRT. Both are able to create toolchains
  42. for many embedded devices. But this is out of the scope of this document.
  43. If you are unable to walk through thousands of configuration options and make
  44. the right choice, you may probably want to try the pre-built binaries.
  45. How to choose a pre-built binary?
  46. ---------------------------------
  47. The directory structure for the binaries is
  48. binaries
  49. +
  50. +--<operating system>
  51. +
  52. +--<cpu arch>
  53. +
  54. +--<endianess> (omitted if CPU or OS does not allow multi-endianess)
  55. +
  56. +--<C-library>
  57. <C-library> can also be "static". That means no special library is required.
  58. Static binaries are much bigger and need more RAM than dynamic binaries but
  59. are more likely to run on your system. Use a static binary only, if none of
  60. the dynmic binaries run.
  61. Don't get confused when a binary is named after an OS or a specific device,
  62. e.g. the name contains "openwrt", "tomato" or "Fritzbox". This does not mean
  63. that the binary will run only on that OS or on that device. It is a hint only
  64. where I got or built the toolchain from.
  65. How to determine the endianess of my system?
  66. --------------------------------------------
  67. - All Intel CPUs (x86, x32, x64) are little-endian only
  68. - Windows is little-endian only even if the CPU support big-endian
  69. - big-endian ARM is extremely uncommon. You can safely assume little-endian
  70. - little-endian PowerPC virtually does not exist since only newer POWER7
  71. and POWER8 CPUs support it. Always assume big-endian.
  72. - For MIPS both little-endian and big-endian are common. Most Broadcomm and
  73. TI chips run little-endian. Most Atheros and Ikanos CPUs run big-endian.
  74. Try typing
  75. echo -n I | od -o | awk 'FNR==1{ print substr($2,6,1)}'
  76. This returns 1 for little-endian systems and 0 for big-endian systems. However
  77. some devices do not have the od command and thus this method won't work.