Luaのコンパイルとインストールプロセス

4261 ワード


一、コンパイル
In most Unix-like platforms, simply do "make"with a suitable target. Here are the details.
  • Open a terminal window and move to the top-level directory, which is named lua-5.2.3. The Makefile there controls both the build process and the installation process.
  • Do "make"and see if your platform is listed. The platforms currently supported are: aix ansi bsd freebsd generic linux macosx mingw posix solaris If your platform is listed, just do "make xxx", where xxx is your platform name. If your platform is not listed, try the closest one or posix, generic, ansi, in this order.
  • The compilation takes only a few moments and produces three files in the src directory: lua (the interpreter), luac (the compiler), and liblua.a (the library).
  • To check that Lua has been built correctly, do "make test"after building Lua. This will run the interpreter and print its version string.

  • If you're running Linux and get compilation errors, make sure you have installed the readline development package. If you get link errors after that, then try "make linux MYLIBS=-ltermcap".
     
    二、取り付け
    Once you have built Lua, you may want to install it in an official place in your system. In this case, do "make install". The official place and the way to install files are defined in the Makefile. You'll probably need the right permissions to install files.
    To build and install Lua in one step, do "make xxx install", where xxx is your platform name.
    To install Lua locally, do "make local". This will create a directory install with subdirectories bin, include, lib, man, and install Lua as listed below. To install Lua locally, but in some other directory, do "make install INSTALL_TOP=xxx", where xxx is your chosen directory.
    bin:
    lua luac
    include:
    lua.h luaconf.h lualib.h lauxlib.h lua.hpp
    lib:
    liblua.a
    man/man1:
    lua.1 luac.1
    These are the only directories you need for development. If you only want to run Lua programs, you only need the files in bin and man. The files in include and lib are needed for embedding Lua in C or C++ programs.
     
    三、カスタマイズ
    Three kinds of things can be customized by editing a file:
  • Where and how to install Lua — edit Makefile.
  • How to build Lua — edit src/Makefile.
  • Lua features — edit src/luaconf.h.

  • You don't actually need to edit the Makefiles because you may set the relevant variables in the command line when invoking make. Nevertheless, it's probably best to edit and save the Makefiles to record the changes you need.
    On the other hand, if you need to customize some Lua features, you'll need to edit src/luaconf.h before building and installing Lua. The edited file will be the one installed, and it will be used by any Lua clients that you build, to ensure consistency. Further customization is available to experts by editing the Lua sources.
    We strongly recommend that you enable dynamic loading in src/luaconf.h. This is done automatically for all platforms listed above that have this feature and also for Windows.
     
    四、Linuxの下でLuaをコンパイルして直面する可能性のある問題
    1.readlineライブラリがインストールされていません.解決方法:readlineライブラリのインストール
    2.次のエラーを報告
    /usr/local/lib/libreadline.so: undefined reference to `tgetnum'/usr/local/lib/libreadline.so: undefined reference to `tgoto'/usr/local/lib/libreadline.so: undefined reference to `tgetflag'/usr/local/lib/libreadline.so: undefined reference to `BC'/usr/local/lib/libreadline.so: undefined reference to `tputs'/usr/local/lib/libreadline.so: undefined reference to `PC'/usr/local/lib/libreadline.so: undefined reference to `tgetent'/usr/local/lib/libreadline.so: undefined reference to `UP'/usr/local/lib/libreadline.so: undefined reference to `tgetstr'
    解決方法:luaコンパイルはreadlineライブラリに依存し、ncursesライブラリに依存するが、指定されていないため、「未定義の適合参照」エラーが発生し、次のようにコンパイルできます.
    make linux MYLIBS=-lncurses
     
    3.新聞cannot find-lncurses
    解決策:ncurses=>yum install ncurses-develをインストールする必要があります
     
    (全文完了)