FAQ.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
  2. <HTML>
  3. <HEAD>
  4. <TITLE>uClibc FAQ-- a C library for embedded systems</TITLE>
  5. </HEAD>
  6. <body text="#000000" alink="#660000" link="#660000" bgcolor="#dee2de" vlink="#660000">
  7. <basefont face="lucida, helvetica, arial" size="3">
  8. <CENTER>
  9. <p>
  10. <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2>
  11. <TR>
  12. <td bgcolor="#000000">
  13. <FONT FACE="lucida, helvetica" COLOR="#ccccc0">
  14. <B>µ&nbsp;C&nbsp;l&nbsp;i&nbsp;b&nbsp;c</B>
  15. </FONT>
  16. </TD>
  17. </TR>
  18. </TABLE>
  19. <p>
  20. <!-- Begin NOT Working List -->
  21. <TABLE WIDTH=95% CELLSPACING=1 CELLPADDING=4 BORDER=1>
  22. <TR><TD BGCOLOR="#ccccc0" ALIGN=center>
  23. <A NAME="notworking"> <BIG><B>
  24. uClibc Frequently Asked Questions (FAQ)
  25. </font>
  26. </A></B></BIG>
  27. </TD></TR>
  28. <TR><TD BGCOLOR="#eeeee0">
  29. <p>
  30. This is a collection of some of the frequently asked questions
  31. about uClibc. Some of the questions even have answers. If you
  32. have additions to this FAQ document, we would love to add them,
  33. <br>
  34. When you are done, <a href="http://uclibc.org/">you can click here to return
  35. to the uClibc home page.</a>
  36. <p>
  37. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  38. <B>
  39. What platforms does uClibc run on?
  40. </B>
  41. </TD></TR>
  42. <TR><TD BGCOLOR="#eeeee0">
  43. Currently uClibc runs on alpha, ARM, i386, i960, h8300, m68k, mips/mipsel,
  44. PowerPC, SH, SPARC, and v850 processors.
  45. <p>
  46. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  47. <B>
  48. Why is it called uClibc?
  49. </B>
  50. </TD></TR>
  51. <TR><TD BGCOLOR="#eeeee0">
  52. The letter 'u' is short for µ (the greek letter "mu"). µ is commonly used
  53. as the abbreviation for the word "micro". The capital "C" is short for
  54. "controller". So the name uClibc is sortof an abbreviation for "the
  55. microcontroller C library". For simplicity, uClibc is pronounced
  56. "yew-see-lib-see".
  57. <p>
  58. The name is partly historical, since uClibc was originally
  59. created to support <a href="http://www.uclinux.org">µClinux</a>, a port of
  60. Linux for MMU-less microcontrollers such as the Dragonball, Coldfire, and
  61. ARM7TDMI. These days, uClibc also works just fine on normal Linux systems
  62. (such as i386, ARM, and PowerPC), but we couldn't think of a better name.
  63. <p>
  64. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  65. <B>
  66. Can I use it on my desktop i386 system?
  67. </B>
  68. </TD></TR>
  69. <TR><TD BGCOLOR="#eeeee0">
  70. Sure! In fact, this can be very nice during development. By
  71. installing uClibc on your development system, you can be sure that
  72. the code you are working on will actually run when you deploy it
  73. your target system.
  74. <p>
  75. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  76. <B>
  77. Does uClibc support shared libraries?
  78. </B>
  79. </TD></TR>
  80. <TR><TD BGCOLOR="#eeeee0">
  81. Yes. uClibc has native shared library support on i386, ARM, mips/mipsel,
  82. SH, and PowerPC processors. Other architectures can use shared libraries
  83. but will need to use the GNU libc shared library loader.
  84. <p>
  85. Shared Libraries are not currently supported by uClibc on MMU-less systems.
  86. <a href="http://www.snapgear.com/">SnapGear</a> has implemented
  87. shared library support for MMU-less systems, however, so if you need MMU-less
  88. shared library support they may be able to help.
  89. <p>
  90. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  91. <B>
  92. Why are you doing this? What's wrong with glibc?
  93. </B>
  94. </TD></TR>
  95. <TR><TD BGCOLOR="#eeeee0">
  96. Initially, the project began since the GNU C library lacks support for
  97. MMU-less systems, and because glibc is very large. The GNU C library is
  98. designed with a very different set of goals then uClibc. The GNU C library
  99. is a great piece of software, make no mistake. It is compliant with just
  100. about every standard ever created, and runs on just about every operating
  101. system and architecture -- no small task! But there is a price to be paid
  102. for that. It is quite a large library, and keeps getting larger with each
  103. release. It does not even pretend to target embedded systems. To quote
  104. from Ulrich Drepper, the maintainer of GNU libc: "...glibc is not the right
  105. thing for [an embedded OS]. It is designed as a native library (as opposed
  106. to embedded). Many functions (e.g., printf) contain functionality which is
  107. not wanted in embedded systems." 24 May 1999
  108. <p>
  109. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  110. <B>
  111. So uClibc is smaller then glibc? Doesn't that mean it completely sucks?
  112. How could it be smaller and not suck?
  113. </B>
  114. </TD></TR>
  115. <TR><TD BGCOLOR="#eeeee0">
  116. uClibc has been designed from the ground up to be a C library for
  117. embedded Linux. We don't need to worry about things like MS-DOS
  118. support, or BeOS, or AmigaOs any other system. This lets us cut out
  119. a lot of complexity and very carefully optimize for Linux. By very
  120. careful design, we can also take a few shortcuts. For example, glibc
  121. contains an implementation of the wordexp() function, in compliance
  122. with the Single Unix Specification, version 3. Well, standards are
  123. important. But so is pragmatism. The wordexp function is huge, yet I
  124. am not aware of even one Linux application that uses it! So uClibc
  125. doesn't provide wordexp(). There are many similar examples. In other
  126. cases, uClibc leaves certain features (such as full C99 Math library
  127. support, IPV6, and RPC support) disabled by default. Those features
  128. can be enabled for people that need them, but are otherwise disabled to
  129. save space.
  130. <p>
  131. Glibc is a general purpose C library, and so as policy things are optimized
  132. for speed. Most of uClibc's routines have been very carefully written to
  133. optimize them for size instead.
  134. <p>
  135. The end result is a C library that will compile just about everything you
  136. throw at it, that looks like glibc to application programs when you
  137. compile, but is many times smaller.
  138. <p>
  139. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  140. <B>
  141. Why should I use uClibc?
  142. </B>
  143. </TD></TR>
  144. <TR><TD BGCOLOR="#eeeee0">
  145. I don't know if you should use uClibc or not. It depends on your needs.
  146. If you are building an embedded Linux system and you are tight on space, then
  147. using uClibc instead if glibc may be a very good idea.
  148. If you are trying to build a huge fileserver for your company that will
  149. have 12 Terabytes of storage, then using glibc may make more sense.
  150. Unless, for example, that 12 Terabytes will be Network Attached Storage
  151. and you plan to burn Linux into the system's firmware...
  152. <p>
  153. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  154. <B>
  155. If I use uClibc, do I have to release all my source code to the world for
  156. free? I want to create a closed source commercial application and I want
  157. to protect my intellectual property.
  158. </B>
  159. </TD></TR>
  160. <TR><TD BGCOLOR="#eeeee0">
  161. No, you do not need to give away your source code just because you use
  162. uClibc and/or run on Linux. uClibc is licensed under the LGPL, just like
  163. GNU libc. Using shared libraries makes complying with the license easy.
  164. If you are using uClibc as a shared library, then your closed source
  165. application is 100% legal. Please consider sharing some of the money you
  166. make with us! :-)
  167. <p>
  168. If you are statically linking your closed source application with
  169. uClibc, then you must take additional steps to comply with the uClibc
  170. license. You may sell your statically linked application as usual, but
  171. you must also make your application available to your customers as an
  172. object file which can later be re-linked against updated versions of
  173. uClibc. This will (in theory) allow your customers to apply uClibc bug
  174. fixes to your application. You do not need to make the application
  175. object file available to everyone, just to those you gave the fully
  176. linked application.
  177. <p>
  178. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  179. <B>
  180. How do I compile programs with uClibc?
  181. </B>
  182. </TD></TR>
  183. <TR><TD BGCOLOR="#eeeee0">
  184. The easiest way is to use the compiler wrapper built by uClibc. Instead of
  185. using your usual compiler or cross compiler, you can use i386-uclibc-gcc,
  186. (or whatever is appropriate for your target architecture) and your
  187. applications will auto-magically link against uClibc. You can also
  188. build your own native uClibc toolchain. Just download the uClibc toolchain
  189. builder from <a href="http://www.uclibc.org/downloads/toolchain/">
  190. http://www.uclibc.org/downloads/toolchain/</a>, ajust the Makefile settings
  191. to match your target system, and then run 'make'.
  192. <p>
  193. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  194. <B>
  195. I have code that uses constructors and destructors. Why is it
  196. when I use uClibc, the ctors/dtors do not run?
  197. </B>
  198. </TD></TR>
  199. <TR><TD BGCOLOR="#eeeee0">
  200. The uClibc compiler wrapper toolchain by default, does not
  201. enable constructor and destructor support for C code. It
  202. only enables ctors/dtors support by default for C++ code.
  203. If you have C code that uses ctors/dtors and you wish to use
  204. the uClibc compiler wrapper toolchain, you will need to add
  205. the <b>--uclibc-ctors</b> option to the gcc command line. i.e.
  206. <PRE>
  207. $ cat test.c
  208. #include <unistd.h>
  209. void __attribute__((constructor)) my_ctor(void)
  210. {
  211. char msg[]="I am a constructor!\n";
  212. write(2, msg, sizeof(msg));
  213. }
  214. int main(void)
  215. {
  216. _exit(42);
  217. }
  218. $ /usr/i386-linux-uclibc/bin/i386-uclibc-gcc --uclibc-ctors ./test.c -o test
  219. $ ./test
  220. I am a constructor!
  221. </PRE>
  222. Another option is to build a native uClibc toolchain. Native toolchains
  223. always enable ctors/dtors support, even for C code.
  224. <p>
  225. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  226. <B>
  227. How do I make autoconf and automake behave?
  228. </B>
  229. </TD></TR>
  230. <TR><TD BGCOLOR="#eeeee0">
  231. First run
  232. <pre>export PATH=/usr/i386-linux-uclibc/bin:$PATH</pre>
  233. (or similar adjusted for your target architecture) then run you can simply
  234. run autoconf/automake and it should _just work_.
  235. <p>
  236. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  237. <B>
  238. When I run 'ldd' to get a list of the library dependencies for a uClibc
  239. binary, ldd segfaults! What should I do?
  240. </B>
  241. </TD></TR>
  242. <TR><TD BGCOLOR="#eeeee0">
  243. Use the ldd that is built by uClibc, not your system's one. When your
  244. system's ldd looks for library dependencies, it actually _runs_ that
  245. program. This works fine -- usually. It generally will not work at all
  246. when you have been cross compiling (which is why ldd segfaults). The ldd
  247. program created by uClibc is cross platform and doesn't even try to run
  248. the target program (like your system one does). So use the uClibc one
  249. and it will do the right thing, and it won't segfault even when you are
  250. cross compiling.
  251. <p>
  252. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  253. <B>
  254. Why does localtime() return times in UTC even when I have my timezone set?
  255. </B>
  256. </TD></TR>
  257. <TR><TD BGCOLOR="#eeeee0">
  258. The uClibc time functions get timezone information from the TZ environment
  259. variable, as described in the Single Unix Specification Version 3. See
  260. <a href="http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap08.html">
  261. http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap08.html</a>
  262. for details on valid settings of TZ. For some additional examples, read
  263. <a href="http://www.uclibc.org/lists/uclibc/2002-August/006261.html">
  264. http://www.uclibc.org/lists/uclibc/2002-August/006261.html</a> in the uClibc
  265. mailing list archive.
  266. <p>
  267. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  268. <B>
  269. What is the history of uClibc? Where did it come from?
  270. </B>
  271. </TD></TR>
  272. <TR><TD BGCOLOR="#eeeee0">
  273. The history and origin of uClibc is long and twisty.
  274. In the beginning, there was <a href="http://www.gnu.org/software/libc/libc.html">GNU libc</a>. Then, libc4
  275. (which later became linux libc 5) forked from GNU libc version 1.07.4, with
  276. additions from 4.4BSD, in order to support Linux. Later, the <a
  277. href="http://www.cix.co.uk/~mayday/">Linux-8086 C library</a>, which is part of
  278. the <a href="http://www.elks.ecs.soton.ac.uk/">elks project</a>, was created,
  279. which was, apparently, largely written from scratch but also borrowed code from
  280. libc4, glibc, some Atari library code, with bits and pieces from about 20 other
  281. places. Then uClibc forked off from the Linux-8086 C library in order to run
  282. on <a href="http://www.uclinux.org">µClinux</a>.
  283. <p>
  284. I had for some time been despairing over the state of C libraries in Linux.
  285. GNU libc, the standard, is very poorly suited to embedded systems and
  286. has been getting bigger with every release. I spent quite a bit of time looking over the
  287. available Open Source C libraries that I knew of (listed below), and none of them really
  288. impressed me. I felt there was a real vacancy in the embedded Linux ecology.
  289. The closest library to what I imagined an embedded C library should be was
  290. uClibc. But it had a lot of problems too -- not the least of which was that,
  291. traditionally, uClibc had a complete source tree fork in order to support each
  292. and every new platform. This resulted in a big mess of twisty versions, all
  293. different. I decided to fix it and the result is what you see here.
  294. My source tree has now become the official uClibc source tree and it now lives
  295. on cvs.uclinux.org and www.uclibc.org.
  296. <p>
  297. To start with, (with some initial help from <a
  298. href="http://www.uclinux.org/developers/">D. Jeff Dionne</a>), I
  299. ported it to run on i386. I then grafted in the header files from glibc 2.1.3
  300. and cleaned up the resulting breakage. This (plus some additional work) has
  301. made it almost completely independent of kernel headers, a large departure from
  302. its traditional tightly-coupled-to-the-kernel origins. I have written and/or
  303. rewritten a number of things that were missing or broken, and sometimes grafted
  304. in bits of code from the current glibc and libc5. I have also built a proper
  305. platform abstraction layer, so now you can simply edit the file "Config" and
  306. use that to decide which architecture you will be compiling for, and whether or
  307. not your target has an MMU, and FPU, etc. I have also added a test suite,
  308. which, though incomplete, is a good start. Several people have helped by
  309. contributing ports to new architectures, and a lot of work has been done on
  310. adding support for missing features.
  311. <p>
  312. These days, uClibc is being developed and enhanced by Erik Andersen of
  313. <a href="http://codepoet-consulting.com/">CodePoet Consulting</a> along
  314. with the rest of the embedded Linux community.
  315. <p>
  316. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  317. <B>
  318. I demand that you to add &lt;favorite feature&gt; right now! How come
  319. you don't answer all my questions on the mailing list instantly? I demand
  320. that you help me with all of my problems <em>Right Now</em>!
  321. </B>
  322. </TD></TR>
  323. <TR><TD BGCOLOR="#eeeee0">
  324. You have not paid us a single cent and yet you still have the
  325. product of nearly two years of work from Erik and Manuel and
  326. many other people. We are not your slaves! We work on uClibc
  327. because we find it interesting. If you go off flaming us, we will
  328. ignore you.
  329. <p>
  330. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  331. <B>
  332. I need you to add &lt;favorite feature&gt;! Are the uClibc developers willing to
  333. be paid in order to fix bugs or add in &lt;favorite feature&gt;? Are you willing to provide
  334. support contracts?
  335. </B>
  336. </TD></TR>
  337. <TR><TD BGCOLOR="#eeeee0">
  338. Sure! Now you have our attention! What you should do is contact <a
  339. href="mailto:andersen@codepoet.org">Erik Andersen</a> of <a
  340. href="http://codepoet-consulting.com/">CodePoet Consulting</a> to bid
  341. on your project. If Erik is too busy to personally add your feature, there
  342. are several other active uClibc contributors who will almost certainly be able
  343. to help you out. Erik can contact them and ask them about their availability.
  344. <p>
  345. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  346. <B>
  347. I think you guys are great and I want to help support your work!
  348. </B>
  349. </TD></TR>
  350. <TR><TD BGCOLOR="#eeeee0">
  351. Wow, that would be great! You can click here to help support uClibc and/or request features.
  352. <!-- Begin PayPal Logo -->
  353. <center>
  354. <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
  355. <input type="hidden" name="cmd" value="_xclick">
  356. <input type="hidden" name="business" value="andersen@codepoet.org">
  357. <input type="hidden" name="item_name" value="Support uClibc and/or request features">
  358. <input type="hidden" name="image_url" value="https://codepoet-consulting.com/images/codepoet.png">
  359. <input type="hidden" name="no_shipping" value="1">
  360. <input type="image" src="images/donate.png" border="0" name="submit" alt="Make donation using PayPal">
  361. </form>
  362. </center>
  363. <!-- End PayPal Logo -->
  364. If you prefer to contact us directly for payments (Erik has a credit card machine so
  365. you can avoid making payments online), hardware donations, support requests, etc., you can
  366. contact <a href="http://codepoet-consulting.com/">CodePoet Consulting</a> here.
  367. <p>
  368. <TR><TD BGCOLOR="#ccccc0" ALIGN=left>
  369. <B>
  370. Ok, I'm done reading all these questions.
  371. </B>
  372. </TD></TR>
  373. <TR><TD BGCOLOR="#eeeee0">
  374. <a href="http://uclibc.org/">Well then, click here to return to the uClibc home page.</a>
  375. <!-- End things -->
  376. </TD></TR>
  377. </TABLE>
  378. </P>
  379. <!-- Footer -->
  380. <HR>
  381. <TABLE WIDTH="100%">
  382. <TR>
  383. <TD>
  384. <font size="-1" face="arial, helvetica, sans-serif">
  385. Mail all comments, insults, suggestions and bribes to
  386. <a href="mailto:andersen@codepoet.org">Erik Andersen</a><BR>
  387. </font>
  388. </TD>
  389. <TD>
  390. <a href="http://www.vim.org"><img border=0 width=90 height=36
  391. src="images/written.in.vi.png"
  392. alt="This site created with the vi editor"></a>
  393. </TD>
  394. <TD>
  395. <a href="http://www.gimp.org/"><img border=0 width=90 height=36
  396. src="images/gfx_by_gimp.png" alt="Graphics by GIMP"></a>
  397. </TD>
  398. <TD>
  399. <a href="http://www.linuxtoday.com"><img width=90 height=36
  400. src="images/ltbutton2.png" alt="Linux Today"></a>
  401. </TD>
  402. <TD>
  403. <p><a href="http://slashdot.org"><img width=90 height=36
  404. src="images/sdsmall.png" alt="Slashdot"></a>
  405. </TD>
  406. <TD>
  407. <a href="http://freshmeat.net"><img width=90 height=36
  408. src="images/fm.mini.png" alt="Freshmeat"></a>
  409. </TD>
  410. </TR>
  411. </TABLE>
  412. </CENTER>
  413. </BODY>
  414. </HTML>