- vs 创建dll空项目
- 引入protobuf-gen-lua工程里的pb.c文件
- 修改原程序
1 #ifndef _WIN32
2 #include <endian.h>
3 #endif
1 static int struct_unpack(lua_State *L)
2 {
3 uint8_t format = luaL_checkinteger(L, 1);
4 size_t len;
5 const uint8_t* buffer = (uint8_t*)luaL_checklstring(L, 2, &len);
6 size_t pos = luaL_checkinteger(L, 3);
7 uint8_t out[8];
8 buffer += pos;
1 __declspec(dllexport)
2 int luaopen_pb (lua_State *L)
- 添加main方法
1 int main(int argc, char* argv[])
2 {
3 lua_State *L = lua_open();
4 //luaL_openlibs(L);
5 luaopen_pb(L);
6 lua_close(L);
7 return 0;
8 }
- 配置工程头文件及库路径:
- 配置属性->VC++目录->包含目录-><pathto>/lua/include
- 配置属性->VC++目录->库目录-><pathto>/lua/lib
- 配置属性->链接器->附加依赖项->lua51.lib
-
- 配置属性
- ->VC++目录->包含目录-><pathto>/lua/include
转载于:https://www.cnblogs.com/moonbear/p/3489919.html