install.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <title>Installation</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <meta name="Author" content="Mike Pall">
  7. <meta name="Copyright" content="Copyright (C) 2005-2010, Mike Pall">
  8. <meta name="Language" content="en">
  9. <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
  10. <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
  11. </head>
  12. <body>
  13. <div id="site">
  14. <a href="http://luajit.org"><span>Lua<span id="logo">JIT</span></span></a>
  15. </div>
  16. <div id="head">
  17. <h1>Installation</h1>
  18. </div>
  19. <div id="nav">
  20. <ul><li>
  21. <a href="luajit.html">LuaJIT</a>
  22. <ul><li>
  23. <a class="current" href="install.html">Installation</a>
  24. </li><li>
  25. <a href="running.html">Running</a>
  26. </li><li>
  27. <a href="api.html">API Extensions</a>
  28. </li></ul>
  29. </li><li>
  30. <a href="status.html">Status</a>
  31. <ul><li>
  32. <a href="changes.html">Changes</a>
  33. </li></ul>
  34. </li><li>
  35. <a href="faq.html">FAQ</a>
  36. </li><li>
  37. <a href="http://luajit.org/download.html">Download <span class="ext">&raquo;</span></a>
  38. </li></ul>
  39. </div>
  40. <div id="main">
  41. <p>
  42. LuaJIT is only distributed as a source package. This page explains
  43. how to build and install LuaJIT with different operating systems
  44. and C&nbsp;compilers.
  45. </p>
  46. <p>
  47. For the impatient (on POSIX systems):
  48. </p>
  49. <pre class="code">
  50. make &amp;&amp; sudo make install
  51. </pre>
  52. <p>
  53. LuaJIT currently builds out-of-the box on all popular x86 systems
  54. (Linux, Windows, OSX etc.). It builds and runs fine as a 32&nbsp;bit
  55. application under x64-based systems, too.
  56. </p>
  57. <p class="indent" style="color: #00a000;">
  58. The x64 port of LuaJIT is still experimental and not enabled by default.
  59. It only contains the interpreter and only builds on Linux/x64 and WIN64
  60. right now. If you want to give it a try, follow the special build instructions
  61. below.
  62. </p>
  63. <p class="indent" style="color: #00a000;">
  64. Note that the pure interpreter is quite a bit faster than Lua, but of
  65. course not as fast as the x86 JIT compiler. Work on the x64 JIT compiler
  66. is still ongoing.
  67. </p>
  68. <h2>Configuring LuaJIT</h2>
  69. <p>
  70. The standard configuration should work fine for most installations.
  71. Usually there is no need to tweak the settings. The following files
  72. hold all user-configurable settings:
  73. </p>
  74. <ul>
  75. <li><tt>src/luaconf.h</tt> sets some configuration variables.</li>
  76. <li><tt>Makefile</tt> has settings for <b>installing</b> LuaJIT (POSIX
  77. only).</li>
  78. <li><tt>src/Makefile</tt> has settings for <b>compiling</b> LuaJIT
  79. under POSIX, MinGW and Cygwin.</li>
  80. <li><tt>src/msvcbuild.bat</tt> has settings for compiling LuaJIT with
  81. MSVC.</li>
  82. </ul>
  83. <p>
  84. Please read the instructions given in these files, before changing
  85. any settings.
  86. </p>
  87. <h2 id="posix">POSIX Systems (Linux, OSX, *BSD etc.)</h2>
  88. <h3>Prerequisites</h3>
  89. <p>
  90. Depending on your distribution, you may need to install a package for
  91. GCC (GCC 3.4 or later required), the development headers and/or a
  92. complete SDK.
  93. </p>
  94. <p>
  95. E.g. on a current Debian/Ubuntu, install <tt>libc6-dev</tt>
  96. with the package manager. Currently LuaJIT builds as a 32&nbsp;bit
  97. application by default, so you actually need to install <tt>libc6-dev-i386</tt>
  98. when building on an x64 OS.
  99. </p>
  100. <p>
  101. Download the current source package (pick the .tar.gz), if you haven't
  102. already done so. Move it to a directory of your choice, open a
  103. terminal window and change to this directory. Now unpack the archive
  104. and change to the newly created directory:
  105. </p>
  106. <pre class="code">
  107. tar zxf LuaJIT-2.0.0-beta2.tar.gz
  108. cd LuaJIT-2.0.0-beta2</pre>
  109. <h3>Building LuaJIT</h3>
  110. <p>
  111. The supplied Makefiles try to auto-detect the settings needed for your
  112. operating system and your compiler. They need to be run with GNU Make,
  113. which is probably the default on your system, anyway. Simply run:
  114. </p>
  115. <pre class="code">
  116. make
  117. </pre>
  118. <div style="color: #00a000;">
  119. <p>
  120. You can force a build of the x64 interpreter on Linux/x64 with the
  121. following command:
  122. </p>
  123. <pre class="code">
  124. make CC="gcc -m64"
  125. </pre>
  126. </div>
  127. <p>
  128. By default modules are only searched under the prefix <tt>/usr/local</tt>.
  129. You can add an extra prefix to the search paths by appending the
  130. <tt>PREFIX</tt> option, e.g.:
  131. </p>
  132. <pre class="code">
  133. make PREFIX=/home/myself/lj2
  134. </pre>
  135. <p>
  136. Note for OSX: <tt>MACOSX_DEPLOYMENT_TARGET</tt> is set to <tt>10.4</tt>
  137. in <tt>src/Makefile</tt>. Change it, if you want to build on an older version.
  138. </p>
  139. <h3>Installing LuaJIT</h3>
  140. <p>
  141. The top-level Makefile installs LuaJIT by default under
  142. <tt>/usr/local</tt>, i.e. the executable ends up in
  143. <tt>/usr/local/bin</tt> and so on. You need root privileges
  144. to write to this path. So, assuming sudo is installed on your system,
  145. run the following command and enter your sudo password:
  146. </p>
  147. <pre class="code">
  148. sudo make install
  149. </pre>
  150. <p>
  151. Otherwise specify the directory prefix as an absolute path, e.g.:
  152. </p>
  153. <pre class="code">
  154. make install PREFIX=/home/myself/lj2
  155. </pre>
  156. <p>
  157. Obviously the prefixes given during build and installation need to be the same.
  158. </p>
  159. <p style="color: #c00000;">
  160. Note: to avoid overwriting a previous version, the beta test releases
  161. only install the LuaJIT executable under the versioned name (i.e.
  162. <tt>luajit-2.0.0-beta2</tt>). You probably want to create a symlink
  163. for convenience, with a command like this:
  164. </p>
  165. <pre class="code" style="color: #c00000;">
  166. sudo ln -sf luajit-2.0.0-beta2&nbsp;/usr/local/bin/luajit
  167. </pre>
  168. <h2 id="windows">Windows Systems</h2>
  169. <h3>Prerequisites</h3>
  170. <p>
  171. Either install one of the open source SDKs
  172. (<a href="http://mingw.org/"><span class="ext">&raquo;</span>&nbsp;MinGW</a> or
  173. <a href="http://www.cygwin.com/"><span class="ext">&raquo;</span>&nbsp;Cygwin</a>), which come with a modified
  174. GCC plus the required development headers.
  175. </p>
  176. <p>
  177. Or install Microsoft's Visual C++ (MSVC). The freely downloadable
  178. <a href="http://www.microsoft.com/Express/VC/"><span class="ext">&raquo;</span>&nbsp;Express Edition</a>
  179. works just fine, but only contains an x86 compiler.
  180. </p>
  181. <p>
  182. The freely downloadable
  183. <a href="http://msdn.microsoft.com/en-us/windowsserver/bb980924.aspx"><span class="ext">&raquo;</span>&nbsp;Windows SDK</a>
  184. only comes with command line tools, but this is all you need to build LuaJIT.
  185. It contains x86 and x64 compilers.
  186. </p>
  187. <p>
  188. Next, download the source package and unpack it using an archive manager
  189. (e.g. the Windows Explorer) to a directory of your choice.
  190. </p>
  191. <h3>Building with MSVC</h3>
  192. <p>
  193. Open a "Visual Studio .NET Command Prompt", <tt>cd</tt> to the
  194. directory where you've unpacked the sources and run these commands:
  195. </p>
  196. <pre class="code">
  197. cd src
  198. msvcbuild
  199. </pre>
  200. <p>
  201. Then follow the installation instructions below.
  202. </p>
  203. <h3>Building with the Windows SDK</h3>
  204. <p>
  205. Open a "Windows SDK Command Shell" and select the x86 compiler:
  206. </p>
  207. <pre class="code">
  208. setenv /release /x86
  209. </pre>
  210. <div style="color: #00a000;">
  211. <p>
  212. Or select the x64 compiler (this only builds the interpreter right now):
  213. </p>
  214. <pre class="code">
  215. setenv /release /x64
  216. </pre>
  217. </div>
  218. <p>
  219. Then <tt>cd</tt> to the directory where you've unpacked the sources
  220. and run these commands:
  221. </p>
  222. <pre class="code">
  223. cd src
  224. msvcbuild
  225. </pre>
  226. <p>
  227. Then follow the installation instructions below.
  228. </p>
  229. <h3>Building with MinGW or Cygwin</h3>
  230. <p>
  231. Open a command prompt window and make sure the MinGW or Cygwin programs
  232. are in your path. Then <tt>cd</tt> to the directory where
  233. you've unpacked the sources and run this command for MinGW:
  234. </p>
  235. <pre class="code">
  236. mingw32-make
  237. </pre>
  238. <p>
  239. Or this command for Cygwin:
  240. </p>
  241. <pre class="code">
  242. make
  243. </pre>
  244. <p>
  245. Then follow the installation instructions below.
  246. </p>
  247. <h3>Installing LuaJIT</h3>
  248. <p>
  249. Copy <tt>luajit.exe</tt> and <tt>lua51.dll</tt> (built in the <tt>src</tt>
  250. directory) to a newly created directory (any location is ok).
  251. Add <tt>lua</tt> and <tt>lua\jit</tt> directories below it and copy
  252. all Lua files from the <tt>lib</tt> directory of the distribution
  253. to the latter directory.
  254. </p>
  255. <p>
  256. There are no hardcoded
  257. absolute path names &mdash; all modules are loaded relative to the
  258. directory where <tt>luajit.exe</tt> is installed
  259. (see <tt>src/luaconf.h</tt>).
  260. </p>
  261. <br class="flush">
  262. </div>
  263. <div id="foot">
  264. <hr class="hide">
  265. Copyright &copy; 2005-2010 Mike Pall
  266. <span class="noprint">
  267. &middot;
  268. <a href="contact.html">Contact</a>
  269. </span>
  270. </div>
  271. </body>
  272. </html>