[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Cannot dynamically load executable
- From: Drake Wilson <drake@...>
- Date: Wed, 24 Apr 2013 20:07:42 -0500
Quoth Matt Eisan <mattjeisan@gmail.com>, on 2013-04-24 20:42:40 -0400:
> I have attached the code I am using, and I compile with GCC using g++
> dir.cpp -o test.so -llua
[...]
> int main() {
> return 0;
> }
No, you want to create a shared library, not a main executable file. Use g++
-shared and get rid of main(), to start with. Nor, I think, will it work with
the name 'test.so' but an entrypoint function name of luaopen_mylib; the
expected load name should match the luaopen_* entrypoint and the .so basename,
as in foo.so loaded with require('foo') defining the C function luaopen_foo.
Also, all of the functions you're planning to cast to lua_CFunction (such as
l_dir), as well as the luaopen_* entrypoint, should be extern "C", if I'm not
mistaken. (You'll also want to consider exceptions if you're interfacing to
C++, but that can be later.)
---> Drake Wilson