redis: undefined reference to `log‘

user1@raspberrypi:~/Public/redis-2.0.4-stable $ cc -o redis-server -lm -lpthread -g adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o

/usr/bin/ld: redis.o: in function `computeObjectSwappability':

/home/user1/Public/redis-2.0.4-stable/redis.c:9293:(.text+0x199b8): undefined reference to `log'

collect2: error: ld returned 1 exit status

math库链接上了 -lm 但是还是报错 找不到log自然对数(Natural logarithm)函数

修改Makefile 把*.o 移动到 链接参数前面

redis-server: $(OBJ)

(CC) -o (PRGNAME) (CCOPT) (DEBUG) $(OBJ)

redis-server: $(OBJ)

(CC) -o (PRGNAME) (OBJ) (DEBUG) $(CCOPT)

$ make

...

cc -o redis-server adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o -g -lpthread -lm

$ ./redis-server

9056\] 10 Dec 09:52:13 # Warning: no config file specified, using the default config. In order to specify a config file use 'redis-server /path/to/redis.conf' \[9056\] 10 Dec 09:52:13 \* Server started, Redis version 2.0.4 \[9056\] 10 Dec 09:52:13 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. \[9056\] 10 Dec 09:52:13 \* The server is now ready to accept connections on port 6379 \[9056\] 10 Dec 09:52:13 - 0 clients connected (0 slaves), 821832 bytes in use \[9056\] 10 Dec 09:52:18 - 0 clients connected (0 slaves), 821832 bytes in use 代码下载链接 ```bash ed2k://|file|redis-2.0.4-stable.zip|485917|24CEAB4671C984F169A2160AEFE55154|h=I5RAFGIKIEECN37FZNHN2JSVZFNVAEC3|/ ``` 相关书籍 ed2k://\|file\|Levine%20-%20Linkers%20and%20Loaders%20\[compilers,%20ELF\]%20(Morgan,%202000).djvu\|2265728\|D17EFC39F27205933AE9571E8F7EE617\|h=HIPA4QMJZK7KGNCAFZCKJISCWZODIEHK\|/ ed2k://\|file\|Levine,%20Linkers%20And%20Loaders%20(Morgan%20Kaufmann,%202000).pdf\|18883469\|9E934E3F78C2BABD586670F3815A1166\|h=EP6AOLUQYOADRAGS2M7OV4Y7KS6SKAS2\|/

相关推荐
wyt5314292 小时前
Redis的安装教程(Windows+Linux)【超详细】
linux·数据库·redis
vpk1123 小时前
Docker Compose 安装 Redis
redis·docker·容器
我真会写代码6 小时前
Redis高频面试题(含标准答案,覆盖基础+进阶+实战)
数据库·redis·缓存
6+h7 小时前
【Redis】缓存问题及解决方案
数据库·redis·缓存
6+h8 小时前
【Redis】高可用核心讲解
数据库·redis·缓存
Aloha_up9 小时前
redis与数据库的一致性问题分析
数据库·redis·缓存
6+h9 小时前
【Redis】底层原理解析(SDS / 跳表 / IO多路复用 / 单线程模型)
数据库·redis·bootstrap
知识分享小能手11 小时前
Redis入门学习教程,从入门到精通,Redis集群架构:语法知识点、使用方法与综合案例(6)
redis·学习·架构
czlczl2002092511 小时前
Redis过期删除策略
数据库·redis·缓存
爱学习的小可爱卢13 小时前
Redis从入门到精通:入门到精通(万字详解)
数据库·redis·中间件