我正在尝试在Ubuntu 16.04上编译Redis 4.0.9(最新版本)。在redis目录中运行make时,我得到以下输出:
cd src && make all
make[1]: Entering directory '/user/HS104/m09170/redis/redis-4.0.9/src'
CC Makefile.dep
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep dict-benchmark
(cd ../deps && make distclean)
make[2]: Entering directory '/user/HS104/m09170/redis/redis-4.0.9/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory '/user/HS104/m09170/redis/redis-4.0.9/deps'
(rm -f .make-*)
echo STD=-std=c99 -pedantic -DREDIS_STATIC='' >> .make-settings
echo WARN=-Wall -W -Wno-missing-field-initializers >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS= >> .make-settings
echo REDIS_LDFLAGS= >> .make-settings
echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -DREDIS_STATIC='' -Wall -W -Wno-missing-field-initializers -O2 -g -ggdb -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings
echo PREV_FINAL_LDFLAGS= -g -ggdb -rdynamic >> .make-settings
(cd ../deps && make hiredis linenoise lua jemalloc)
make[2]: Entering directory '/user/HS104/m09170/redis/redis-4.0.9/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-cflags)
(echo "" > .make-ldflags)
MAKE hiredis
cd hiredis && make static
make[3]: Entering directory '/user/HS104/m09170/redis/redis-4.0.9/deps/hiredis'
cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb x86_64 net.c
cc: error: x86_64: No such file or directory
Makefile:156: recipe for target 'net.o' failed
make[3]: *** [net.o] Error 1
make[3]: Leaving directory '/user/HS104/m09170/redis/redis-4.0.9/deps/hiredis'
Makefile:45: recipe for target 'hiredis' failed
make[2]: *** [hiredis] Error 2
make[2]: Leaving directory '/user/HS104/m09170/redis/redis-4.0.9/deps'
Makefile:170: recipe for target 'persist-settings' failed
make[1]: [persist-settings] Error 2 (ignored)
CC adlist.o
In file included from adlist.c:34:0:
zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
compilation terminated.
Makefile:228: recipe for target 'adlist.o' failed
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory '/user/HS104/m09170/redis/redis-4.0.9/src'
Makefile:6: recipe for target 'all' failed
make: *** [all] Error 2
似乎问题与依赖关系有关。如果我进入deps
文件夹并逐个手动编译依赖项,它们都会成功(包括jemalloc),但hiredis除外,它提供以下输出:
user@tefnut:~/redis/redis-4.0.9/deps/hiredis$ make
cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb x86_64 net.c
cc: error: x86_64: No such file or directory
Makefile:156: recipe for target 'net.o' failed
make: *** [net.o] Error 1
我试过make distclean
没有成功。
答案 0 :(得分:1)
解决方案正在运行:
unset ARCH
和/或
unset TARGET_ARCH
之后hiredis编译没有投诉。我不确定为什么有效,所以如果有其他人知道为什么会有所作为,我很好奇。
答案 1 :(得分:0)
在建立依赖关系之前安装build-essential,需要在此处安装gcc。
sudo apt-get install build-essential