cloudwu / pbc

A protocol buffers library for C
MIT License
1.62k stars 568 forks source link

protobuf 编译如何链接lua5.4,风哥是否能说的稍微详细一些。 #142

Closed GameKong closed 3 years ago

GameKong commented 3 years ago

kongling@konglingdeMacBook-Pro skynet % ./skynet ./examples/config [:01000002] LAUNCH snlua bootstrap [:01000003] LAUNCH snlua launcher [:01000004] LAUNCH snlua cmaster [:01000004] master listen socket 0.0.0.0:2013 [:01000005] LAUNCH snlua cslave [:01000005] slave connect to master 127.0.0.1:2013 [:01000004] connect from 127.0.0.1:55198 4 [:01000006] LAUNCH harbor 1 16777221 [:01000004] Harbor 1 (fd=4) report 127.0.0.1:2526 [:01000005] Waiting for 0 harbors [:01000005] Shakehand ready [:01000007] LAUNCH snlua datacenterd [:01000008] LAUNCH snlua service_mgr [:01000009] LAUNCH snlua testproto [:01000009] lua loader error : error loading module 'protobuf.c' from file './luaclib/protobuf.so': dlopen(./luaclib/protobuf.so, 6): Symbol not found: _lua_newuserdatauv Referenced from: ./luaclib/protobuf.so Expected in: flat namespace in ./luaclib/protobuf.so stack traceback: [C]: in ? [C]: in function 'require' ./lualib/protobuf.lua:1: in main chunk [C]: in function 'require' ./test/testproto.lua:2: in local 'main' ./lualib/loader.lua:48: in main chunk [:01000009] KILL self [:01000002] KILL self

风哥,我macOS,编译好protobuf运行失败, 今天回答说是需要链接 lua5.4的.h头文件, 如何链接呢,是编译proto的时候链接吗?折腾了一天还是没解决。。 求帮助 我的make文件如下: CC = gcc CFLAGS = -O2 -Wall -bundle -undefined dynamic_lookup LUADIR = ../../../lua TARGET = protobuf.so

.PHONY : all clean

all : $(TARGET)

$(TARGET) : pbc-lua53.c $(CC) $(CFLAGS) -o $@ -I../.. -I$(LUADIR) -L../../build $^ -lpbc

clean : rm -f $(TARGET)

GameKong commented 3 years ago

我看 skynet ../../../lua 中的源码都已经是5.4了啊

GameKong commented 3 years ago

我下载了哥 lua5.4, 更改了Makefile: CC = gcc CFLAGS = -O2 -Wall -bundle -undefined dynamic_lookup LUADIR = /Users/kongling/Downloads/lua-5.4.1/src TARGET = protobuf.so

.PHONY : all clean

all : $(TARGET)

$(TARGET) : pbc-lua.c $(CC) $(CFLAGS) -o $@ -I../.. -I$(LUADIR) -L../../build $^ -lpbc

clean : rm -f $(TARGET)

编译完还是不行。。 相同的错误

GameKong commented 3 years ago

问题解决了, 具体什么原因还不清楚。 解决方案,就是删除skynet,重新下载了一下,然后make。 就OK了, makefile配置还是我上面写的那个没变。 可能是 之前我makeskynet的时候哪里环境不对导致的