如何在没有安装lua-dev的情况下构建一个c ++程序,它作为lua语言的包装器?

时间:2016-10-26 12:58:16

标签: c++ c lua

当我在没有安装lua-dev的机器中构建c ++程序作为lua语言的包装时,它会输出如下错误信息:

/usr/bin/ld: warning: liblua5.1.so.0, needed by ../build/lib/liblua_print.so, not found (try using -rpath or -rpath-link)
../build/lib/liblua_print.so: undefined reference to `luaL_newstate'
../build/lib/liblua_print.so: undefined reference to `luaL_openlibs'
../build/lib/liblua_print.so: undefined reference to `lua_pcall'
../build/lib/liblua_print.so: undefined reference to `luaL_loadfile'
../build/lib/liblua_print.so: undefined reference to `lua_close'
collect2: ld returned 1 exit status

我的构建过程如下(错误出现在最后一行):

g++ -fPIC -shared -I../include/ -c ./lua_print.cpp -o ../build/object/lua_print.o                                                                                  
g++ -fPIC -shared -o ../build/lib/liblua_print.so ../build/object/lua_print.o -L../lib/ -llua5.1
g++ -fPIC -shared -I. -c ./main.cpp -o ../build/object/main.o
g++ -o ../build/bin/crnn_demo ../build/object/main.o ../build/lib/liblua_print.so

我的节目组织如下:

demo
  lib
    liblua5.1.so (link to liblua5.1.so.0)
    liblua5.1.so.0 (link to liblua5.1.so.0.0.0)
    liblua5.1.so.0.0.0 (copy from another machine that installs lua-dev)
  src
    main.cpp
    lua_print.c
    lua_print.cpp
  include
    lua.hpp (copy from another machine)
    ..(other lua's header file copied from another machine)
  build (result dir)
    object (store main.o, lua_print.o)
    lib (store liblua_print.so)
    bin (store final result)   

0 个答案:

没有答案