quick3.3 protobuf 求问

3.3 创建的项目 在项目目中会有一个protobuf-lite 我看了下是集成了protobuf 2.5.0的,但是好像又不能用的,请问这个是什么情况,能有项目的文档吗

项目试用的protobuf 版本是2.4.1 不知道怎么办了

那个是codeIDE调试时使用的通信协议,和游戏项目的代码是不相关的,所以不能用的。

七月哥,3.3集成protobuf 2.4.1一直不能成功啊

为什么呢?卡在什么地方了?

我编译pb.c 文件一直提示
pb.obj : error LNK2019: 无法解析的外部符号 “void __cdecl lua_settop(struct lua_State *,int)” (?lua_settop@@YAXPAUlua_State@@H@Z),该符号在函数 “int __cdecl varint_encoder(struct lua_State *)” (?varint_encoder@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “void __cdecl lua_pushvalue(struct lua_State *,int)” (?lua_pushvalue@@YAXPAUlua_State@@H@Z),该符号在函数 “int __cdecl luaopen_pb(struct lua_State *)” (?luaopen_pb@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “void __cdecl lua_pushnumber(struct lua_State *,double)” (?lua_pushnumber@@YAXPAUlua_State@@N@Z),该符号在函数 “int __cdecl varint_decoder(struct lua_State *)” (?varint_decoder@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “void __cdecl lua_pushinteger(struct lua_State *,int)” (?lua_pushinteger@@YAXPAUlua_State@@H@Z),该符号在函数 “int __cdecl varint_decoder(struct lua_State *)” (?varint_decoder@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “void __cdecl lua_pushlstring(struct lua_State *,char const *,unsigned int)” (?lua_pushlstring@@YAXPAUlua_State@@PBDI@Z),该符号在函数 “int __cdecl read_tag(struct lua_State *)” (?read_tag@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “void __cdecl lua_getfield(struct lua_State *,int,char const *)” (?lua_getfield@@YAXPAUlua_State@@HPBD@Z),该符号在函数 “int __cdecl iostring_new(struct lua_State *)” (?iostring_new@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “void * __cdecl lua_newuserdata(struct lua_State *,unsigned int)” (?lua_newuserdata@@YAPAXPAUlua_State@@I@Z),该符号在函数 “int __cdecl iostring_new(struct lua_State *)” (?iostring_new@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “void __cdecl lua_setfield(struct lua_State *,int,char const *)” (?lua_setfield@@YAXPAUlua_State@@HPBD@Z),该符号在函数 “int __cdecl luaopen_pb(struct lua_State *)” (?luaopen_pb@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “int __cdecl lua_setmetatable(struct lua_State *,int)” (?lua_setmetatable@@YAHPAUlua_State@@H@Z),该符号在函数 “int __cdecl iostring_new(struct lua_State *)” (?iostring_new@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “void __cdecl lua_call(struct lua_State *,int,int)” (?lua_call@@YAXPAUlua_State@@HH@Z),该符号在函数 “int __cdecl varint_encoder(struct lua_State *)” (?varint_encoder@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “void __cdecl luaL_register(struct lua_State *,char const *,struct luaL_Reg const *)” (?luaL_register@@YAXPAUlua_State@@PBDPBUluaL_Reg@@@Z),该符号在函数 “int __cdecl luaopen_pb(struct lua_State *)” (?luaopen_pb@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “char const * __cdecl luaL_checklstring(struct lua_State *,int,unsigned int *)” (?luaL_checklstring@@YAPBDPAUlua_State@@HPAI@Z),该符号在函数 “int __cdecl varint_decoder(struct lua_State *)” (?varint_decoder@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “double __cdecl luaL_checknumber(struct lua_State *,int)” (?luaL_checknumber@@YANPAUlua_State@@H@Z),该符号在函数 “int __cdecl varint_encoder(struct lua_State *)” (?varint_encoder@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “int __cdecl luaL_checkinteger(struct lua_State *,int)” (?luaL_checkinteger@@YAHPAUlua_State@@H@Z),该符号在函数 “int __cdecl struct_pack(struct lua_State *)” (?struct_pack@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “int __cdecl luaL_newmetatable(struct lua_State *,char const *)” (?luaL_newmetatable@@YAHPAUlua_State@@PBD@Z),该符号在函数 “int __cdecl luaopen_pb(struct lua_State *)” (?luaopen_pb@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “void * __cdecl luaL_checkudata(struct lua_State *,int,char const *)” (?luaL_checkudata@@YAPAXPAUlua_State@@HPBD@Z),该符号在函数 “int __cdecl iostring_str(struct lua_State *)” (?iostring_str@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “int __cdecl luaL_error(struct lua_State *,char const *,…)” (?luaL_error@@YAHPAUlua_State@@PBDZZ),该符号在函数 “int __cdecl struct_pack(struct lua_State *)” (?struct_pack@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “void __cdecl luaL_buffinit(struct lua_State *,struct luaL_Buffer *)” (?luaL_buffinit@@YAXPAUlua_State@@PAUluaL_Buffer@@@Z),该符号在函数 “int __cdecl varint_encoder(struct lua_State *)” (?varint_encoder@@YAHPAUlua_State@@@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “char * __cdecl luaL_prepbuffer(struct luaL_Buffer *)” (?luaL_prepbuffer@@YAPADPAUluaL_Buffer@@@Z),该符号在函数 “void __cdecl pack_varint(struct luaL_Buffer *,unsigned __int64)” (?pack_varint@@YAXPAUluaL_Buffer@@_K@Z) 中被引用
2>pb.obj : error LNK2019: 无法解析的外部符号 “void __cdecl luaL_pushresult(struct luaL_Buffer *)” (?luaL_pushresult@@YAXPAUluaL_Buffer@@@Z),该符号在函数 “int __cdecl varint_encoder(struct lua_State *)” (?varint_encoder@@YAHPAUlua_State@@@Z) 中被引用
2>C:\Users\Administrator\Documents\cocos\mygame\frameworks\runtime-src\proj.win32…/…/…/runtime/win32/mygame.exe : fatal error LNK1120: 21 个无法解析的外部命令
========== 生成: 成功 1 个,失败 1 个,最新 3 个,跳过 0 个 ==========

缺少了某个库,但是我打开项目 还是有lua51.lib库 是不是跟protobuf 2.5.0 冲突呢,还是

经过修改知道原因在哪里了吧,呵呵。可以和大家分享一下你的心得了^_^

跟你遇到相同的问题哦,你后来有没有解决呢?是什么原因啊?麻烦赐教!

添加一个pbc-lua.h 内容是
#ifndef _LUA_PBC_EXTRA_H
#define _LUA_PBC_EXTRA_H

#if __cplusplus
extern “C” {
#endif

#include “lauxlib.h”

int luaopen_protobuf_c(lua_State *L);

#if __cplusplus
}
#endif

#endif

我试了貌似还不行啊!我用的quick-Cocos2dx3.3-rc0版本,我看了quick中带的cjson、lpack那些也不用在头文件中申明extern "C"的,我新加的c文件跟这两个差不多,但是却编不过,很奇怪,多谢指点!

在.c 文件中这样加, 添加红色部分代码
#if __cplusplus
extern “C” {
#endif

int
luaopen_protobuf_c(lua_State *L) {
luaL_Reg reg] = {
{"_env_new" , _env_new },
{"_env_register" , _env_register },
{"_env_type", _env_type },
{"_rmessage_new" , _rmessage_new },
{"_rmessage_delete" , _rmessage_delete },
{"_rmessage_integer" , _rmessage_integer },
{"_rmessage_int32", _rmessage_int32 },
{"_rmessage_int64", _rmessage_int64 },
{"_rmessage_int52", _rmessage_int52 },
{"_rmessage_uint52", _rmessage_uint52 },
{"_rmessage_real" , _rmessage_real },
{"_rmessage_string" , _rmessage_string },
{"_rmessage_message" , _rmessage_message },
{"_rmessage_size" , _rmessage_size },
{"_wmessage_new", _wmessage_new },
{"_wmessage_delete", _wmessage_delete },
{"_wmessage_integer", _wmessage_integer },
{"_wmessage_real", _wmessage_real },
{"_wmessage_string", _wmessage_string },
{"_wmessage_message", _wmessage_message },
{"_wmessage_int32", _wmessage_int32 },
{"_wmessage_int64", _wmessage_int64 },
{"_wmessage_int52", _wmessage_int52 },
{"_wmessage_uint52", _wmessage_uint52 },
{"_wmessage_buffer", _wmessage_buffer },
{"_wmessage_buffer_string", _wmessage_buffer_string },
{"_pattern_new", _pattern_new },
{"_pattern_delete", _pattern_delete },
{"_pattern_size", _pattern_size },
{"_pattern_unpack", _pattern_unpack },
{"_pattern_pack", _pattern_pack },
{"_last_error", _last_error },
{"_decode", _decode },
{"_gc", _gc },
{"_add_pattern", _add_pattern },
{"_add_rmessage", _add_rmessage },
{NULL,NULL},
};

luaL_checkversion(L);
luaL_newlib(L, reg);

return 1;

}

#if __cplusplus
}
#endif

你这个问题我之前也遇到过就是这么解决的。

:867: 终于可以了!多谢多谢!!!
但是还有一点我没想明白,就是quick中自带的lpack、cjson这些c文件,为啥不需要这么做呢?
再次感谢不吝赐教!

这个错误是应为这是一个c方法 但是quick 工程编译是按照C++ 来编译的, 你可以在工程属性里面看得到,所以导致这些方法找不到,必须要用extern “C” { } 告诉编译器 这个方法是C方法。

有没有详细的,也在弄protobuff

有没有一个完整的教程 说实话 新手很难集成和使用 跪求了