[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: The C API used from C++
- From: Dirk Laurie <dirk.laurie@...>
- Date: Thu, 29 Jan 2015 11:15:31 +0200
I'm for the first time ever trying to make a Lua binding to a package
written in C++, not C. I put my .cc file inside the source library of that
package and compile with this in my Makefile (Ubuntu 14.04):
OFILES = [list of .o files to be compiled for the package]
CPPFLAGS = -fPIC
mybinding.so: mybinding.o $(OFILES)
cc -shared -fPIC $(OFILES) mybinding.o -o mybinding.so
The default rule for making an object file comes out as e.g.
g++ -fPIC -c -o mybinding.o mybinding.cc
When I run this, I get:
$ lua -l mybinding
lua: error loading module 'mybinding' from file './mybinding.so':
./mybinding.so: undefined symbol: _Z15lua_createtableP9lua_Stateii
This is clearly some C++ mangling of a call to lua_createtable.
I suspect I should make a special Lua executable using g++ as
compiler instead of cc, but this is the point at which I decide to ask
the experts first!