kuyu@ub16:~/dkuyu/Dropbox/practice/lua/luabind/hellobind$ sudo apt-get install libluabind-dev
kuyu@ub16:~/dkuyu/Dropbox/practice/lua/luabind/hellobind$ sudo apt-get install lua
Consider this hellobind.cpp code:
Then consider this test.lua code:
kuyu@castor-ub:~/dkuyu/Dropbox/practice/lua/luabind/hellobind$ cat test.lua
package.loadlib('./hellobind.so', 'init')()
greet()
To run the test.lua code:
kuyu@castor-ub:~/dkuyu/Dropbox/practice/lua/luabind/hellobind$ cat commands.bash
#!/bin/bash
g++ hellobind.cpp -I/usr/include/lua5.2/ -c -fPIC
g++ -shared -Wl,--whole-archive -o hellobind.so hellobind.o -lluabind -Wl,--no-whole-archive
lua test.lua
kuyu@castor-ub:~/dkuyu/Dropbox/practice/lua/luabind/hellobind$ ./commands.bash
hello world!
Sometimes, loading the C++ library in Lua can be problematic. To see what the problems are when loading the library, you can execute this lua file (execute "lua test1.lua"):
kuyu@castor-ub:~/dkuyu/Dropbox/practice/lua/luabind/hellobind$ cat test1.lua
local initfunction, errormessage = package.loadlib('/home/kuyu/dkuyu/Dropbox/practice/lua/luabind/hellobind.so','init')
if errormessage then
print('Error loading hello_world:', errormessage)
end
kuyu@castor-ub:~/dkuyu/Dropbox/practice/lua/luabind/hellobind$ cat commands.bash
#!/bin/bash
g++ hellobind.cpp -I/usr/include/lua5.2/ -c -fPIC
g++ -shared -Wl,--whole-archive -o hellobind.so hellobind.o -lluabind -Wl,--no-whole-archive
lua test.lua
kuyu@castor-ub:~/dkuyu/Dropbox/practice/lua/luabind/hellobind$ ./commands.bash
hello world!
Sometimes, loading the C++ library in Lua can be problematic. To see what the problems are when loading the library, you can execute this lua file (execute "lua test1.lua"):
kuyu@castor-ub:~/dkuyu/Dropbox/practice/lua/luabind/hellobind$ cat test1.lua
local initfunction, errormessage = package.loadlib('/home/kuyu/dkuyu/Dropbox/practice/lua/luabind/hellobind.so','init')
if errormessage then
print('Error loading hello_world:', errormessage)
end
No comments:
Post a Comment