Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

编译binding/lua53时报错 #154

Open
Wattttz opened this issue Jan 21, 2022 · 3 comments
Open

编译binding/lua53时报错 #154

Wattttz opened this issue Jan 21, 2022 · 3 comments

Comments

@Wattttz
Copy link

Wattttz commented Jan 21, 2022

CentOS 8.2
gcc -O2 -fPIC -Wall -shared -o protobuf.so -I../.. -I/usr/local/include -L../../build pbc-lua53.c -lpbc
/usr/bin/ld: 找不到 -lpbc
collect2: 错误:ld 返回 1
make: *** [Makefile:13:protobuf.so] 错误 1

@fuhao3017
Copy link

CentOS 8.2 gcc -O2 -fPIC -Wall -shared -o protobuf.so -I../.. -I/usr/local/include -L../../build pbc-lua53.c -lpbc /usr/ bin/ld: 找不到 -lpbc collect2: 错误:ld 返回 1 make: *** [Makefile:13:protobuf.so] 错误 1
我也遇到了一样的问题请问有什么解决方法嘛

@NextZeus
Copy link

NextZeus commented Sep 15, 2022

安装gmp

https://gmplib.org/

╭─xiaodong@bogon ~/Downloads/gmp-6.2.1
╰─$ ./configure
╭─xiaodong@bogon ~/Downloads/gmp-6.2.1
╰─$ make
╭─xiaodong@bogon ~/Downloads/gmp-6.2.1
╰─$ sudo make install

安装pbc (需要先安装gmp)

pbc

╭─xiaodong@laowantong ~/Downloads/pbc-0.5.14
╰─$ ./configure
╭─xiaodong@laowantong ~/Downloads/pbc-0.5.14
╰─$ make
╭─xiaodong@laowantong ~/Downloads/pbc-0.5.14
╰─$ sudo make install

修改 3rd/pbc/binding/lua53/Makefile (直接复制替换即可)

#97


CC = gcc
CFLAGS = -O2 -fPIC -Wall -bundle -undefined dynamic_lookup
LUADIR = /usr/local/include
TARGET = protobuf.so

.PHONY : all clean

all : $(TARGET)

$(TARGET) : pbc-lua53.c
	$(CC) $(CFLAGS) -o $@ -I../.. -I$(LUADIR) $^ -l pbc -l lua

clean :
	rm -f $(TARGET)

make编译 & 拷贝文件


╭─xiaodong@laowantong ~/skynet/3rd/pbc/binding/lua53 ‹master●›
╰─$ make
gcc -O2 -fPIC -Wall -bundle -undefined dynamic_lookup -o protobuf.so -I../.. -I/usr/local/include pbc-lua53.c -l pbc -l lua
╭─xiaodong@laowantong ~/skynet/3rd/pbc/binding/lua53 ‹master●›
╰─$ cp protobuf.so  ../../../../luaclib/
╭─xiaodong@laowantong ~/skynet/3rd/pbc/binding/lua53 ‹master●›
╰─$ cp protobuf.lua ../../../../lualib/

@NextZeus
Copy link

另外我发现,brew install pbc 这种方式安装 pbc, 依然会报:ld: library not found for -lpbc 这个错误。 所以应该是mac brew install 姿势不对 找不到pbc. 只有下载源码编译安装才能找到

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants