37

I'm try to setup my Redis server, when execute make command, got error: "jemalloc/jemalloc.h: No such file or directory when making Redis", I have tried all steps I can find, such as make distclean or make MALLOC=libc. I'm working on CentOS, it is working on my another Ubuntu server.

System information: Linux ec4t02229 3.10.0-514.10.2.el7.x86_64 #1 SMP Fri Mar 3 00:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Below is my output, any suggestion would be appreciated.

[root@ec4t02229 redis-4.0.2]# make
cd src && make all
make[1]: Entering directory `/home/fenxiaop/redis-4.0.2/src'
CC Makefile.dep
make[1]: Leaving directory `/home/fenxiaop/redis-4.0.2/src'
make[1]: Entering directory `/home/fenxiaop/redis-4.0.2/src'
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 `/home/fenxiaop/redis-4.0.2/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 `/home/fenxiaop/redis-4.0.2/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 `/home/fenxiaop/redis-4.0.2/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 `/home/fenxiaop/redis-4.0.2/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
make[3]: *** [net.o] Error 1
make[3]: Leaving directory `/home/fenxiaop/redis-4.0.2/deps/hiredis'
make[2]: *** [hiredis] Error 2
make[2]: Leaving directory `/home/fenxiaop/redis-4.0.2/deps'
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    
 #include <jemalloc/jemalloc.h>
                           ^
compilation terminated.
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/home/fenxiaop/redis-4.0.2/src'
make: *** [all] Error 2
Neo Feng
  • 371
  • 1
  • 3
  • 5
  • When I tried to run make MALLOC=libc, got error blow cc: error: ../deps/hiredis/libhiredis.a: No such file or directory cc: error: ../deps/lua/src/liblua.a: No such file or directory make[1]: *** [redis-server] Error 1 make[1]: Leaving directory `/home/fenxiaop/redis-4.0.2/src' make: *** [all] Error 2 – Neo Feng Nov 03 '17 at 04:11
  • 32
    Try this whole sequence: make distclean; make MALLOC=libc; make – antirez Nov 03 '17 at 21:18
  • 3
    This worked for me: https://stackoverflow.com/questions/37103054/redis-installation-fails-when-running-make-command – Andrii Muzalevskyi Nov 19 '17 at 11:19
  • I tried that, didn't work for me. Now I changed my server to Ubuntu from CentOs and installed redis via apt-get install which works well – Neo Feng Nov 29 '17 at 14:07
  • 2
    Need to run "make distclean" first, it set remove all earlier compilation file and then run "make" so here we get new compilation for redis server program. – Dhiral Kaniya May 22 '18 at 08:53

2 Answers2

45

same error I was also in while doing build over redis-6.2.0 .

By executing make distclean I was out from the error


[manjunath@beta-test redis-6.2.0]$ make distclean


Manju N
  • 886
  • 9
  • 14
  • 11
    Had the same issue, it was because of a first failed `make` command due to not updated packages. The second time I ran `make`, the OP's error occurred. Running `make distclean` then `make` again fixed it. – l3utterfly Aug 20 '21 at 08:37
  • thanks, it fixed my problem – Ali Golestan Dec 23 '21 at 15:59
  • this fixed my problem, too. my first run of make failed because i didn't have gcc. – Xel Mar 17 '23 at 00:11
42

Selecting a non-default memory allocator when building Redis is done by setting the MALLOC environment variable. Redis is compiled and linked against libc malloc by default, with the exception of jemalloc being the default on Linux systems. This default was picked because jemalloc has proven to have fewer fragmentation problems than libc malloc.  

To force compiling against libc malloc, use:  

% make MALLOC=libc  

To compile against jemalloc on Mac OS X systems, use:    

% make MALLOC=jemalloc

Source: https://github.com/redis/redis/blob/6.0/README.md#allocator

Dinei
  • 4,494
  • 4
  • 36
  • 60
Esli Silva
  • 521
  • 6
  • 10