昨天要編譯一個64位版本的Redis服務器。運行在Solaris10上面。在編譯的時候碰到一些問題。如今把解決的過程記錄下來。redis
我用的redis的版本是2.2.11,編譯器是gcc4.4.3服務器
第一步修改deps/hiredis/MakeFile架構
修改內容以下:socket
64bit:
@echo ""
@echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386"
@echo ""
$(MAKE) ARCH="-m64"orm
第二部修改src/MakeFile編譯器
ifeq ($(uname_S),SunOS)
CFLAGS?= -std=c99 -pedantic $(OPTIMIZATION) -Wall -W -D__EXTENSIONS__ -D_XPG6 $(ARCH) $(PROF)
CCLINK?= -ldl -lnsl -lsocket -lm -lpthread
DEBUG?= -g -ggdb
64bit:
@echo ""
@echo "WARNING: if it fails under Linux you probably need to install libc6-dev-i386"
@echo ""
$(MAKE) ARCH="-m64"it
64bitgprof:
$(MAKE) PROF="-pg" ARCH="-arch i386"io
好了,MakeFile文件修改完成。試着運行一下。編譯
~/redis/redis/redis-2.2.11$ make 64bitfunction
發現編譯錯誤:
sha1.c:78:2: error: #error "Undefined or invalid BYTE_ORDER"
sha1.c:91:2: error: #error "Endianness not defined!"
sha1.c: In function 'SHA1Transform':
緣由是這臺機器的架構師SunOS x86,它的字節序列是LITTLE_ENDIAN,打開sha1.c文件,文件前面70行都在定義BYTE_ORDER,這裏咱們簡單的加一行就能夠了。
#define BYTE_ORDER LITTLE_ENDIAN
70
71 #if !defined(BYTE_ORDER) || \
72 (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \
73 BYTE_ORDER != PDP_ENDIAN)
74 /* you must determine what the correct bit order is for
75 * your compiler - the next line is an intentional error
76 * which will force your compiles to bomb until you fix
77 * the above macros.
78 */
79 #error "Undefined or invalid BYTE_ORDER"
80 #endif
而後再從新運行make 64bit成功。