0
私はUbuntuのLuabindの例であるhello worldを試していましたが、動作させることはできません。誰もこの例をg ++を使ってUbuntuで動作させる方法を知っていますか?ルアビンンドはどのようにubuntuで動くのですか?
[email protected]:~/dkuyu/Dropbox/practice/lua/luabind$ cat hellobind.cpp
#include <iostream>
#include <luabind/luabind.hpp>
void greet()
{
std::cout << "hello world!\n";
}
extern "C" int init(lua_State* L)
{
using namespace luabind;
open(L);
module(L)
[
def("greet", &greet)
];
return 0;
}
[email protected]:~/dkuyu/Dropbox/practice/lua/luabind$ g++ hellobind.cpp -I/usr/include/lua5.2/ -c -fPIC
[email protected]:~/dkuyu/Dropbox/practice/lua/luabind$ g++ -shared -Wl,--whole-archive -o hellobind.so hellobind.o -lluabind -Wl,--no-whole-archive
[email protected]:~/dkuyu/Dropbox/practice/lua/luabind$ cat test.lua
require 'hellobind'
greet()
[email protected]:~/dkuyu/Dropbox/practice/lua/luabind$ lua test.lua
lua: error loading module 'hellobind' from file './hellobind.so':
./hellobind.so: undefined symbol: luaopen_hellobind
stack traceback:
[C]: in ?
[C]: in function 'require'
test.lua:3: in main chunk
[C]: in ?
[email protected]:~/dkuyu/Dropbox/practice/lua/luabind$
私がluaスクリプトを実行すると、luaは "未定義シンボル:luaopen_hellobind"と文句を言います。次のように
私のシステムの詳細は以下のとおりです。
[email protected]:~/dkuyu/Dropbox/practice/lua/luabind$ dpkg --get-selections | grep -v deinstall | egrep 'lua|boost'
libboost-date-time1.54.0:amd64 install
libboost-dev install
libboost-system1.54.0:amd64 install
libboost1.54-dev install
libboost1.55-tools-dev install
liblua5.2-0:amd64 install
liblua5.2-dev:amd64 install
libluabind-dev install
libluabind-examples install
libluabind0.9.1 install
lua5.2 install
[email protected]:~/dkuyu/Dropbox/practice/lua/luabind$ gcc --version
gcc (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[email protected]:~/dkuyu/Dropbox/practice/lua/luabind$ uname -a
Linux castor-ub 3.19.0-43-generiC#49~14.04.1-Ubuntu SMP Thu Dec 31 15:44:49 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[email protected]:~/dkuyu/Dropbox/practice/lua/luabind$
Zekian、私はあなたの提案を試してみましたが、私はこのエラーを取得する: kuyuする@キャスター-UB:〜/ dkuyu/Dropboxの/練習/ LUA/luabindの$猫test.lua /lib/luabind/luabind $ lua test.lua lu:test.lua:4:luabind:ll:test/luabind/luabind/luabind/luabind/luabind /グローバル 'loadlib'(ゼロ値)を呼び出そうとします。 スタックトレースバック: \t test.lua:4:メインチャンク \t [C]:in? – kurt
ああ、それは新しいバージョンのluaではpackage.loadlibです。 –
こんにちはZekian、残念ながら、それはまだ動作しません。しかし、助けてくれてありがとう。 'kuyu @ castor-ub:〜/ dkuyu/Dropbox/practice/lua/luabind $ cat test.lua package.loadlib( 'hellobind.so'、 'init') greet() kuyu @ castor- UB:〜/ dkuyu/Dropboxの/練習/ LUA/luabindの$ Luaのtest.lua LUA:test.lua:1: \t test.lua::1:nilの値 スタックトレースバックを呼び出すための試みメインチャンク内を \t [C]:in? ' – kurt