大家好!
我现在有一个cent os 64位的系统,想编译一个32位的静态库,该如何编译呢?我要编译的代码如下:
code.google.com/p/spserver ,求大侠指点如何修改这里面的makefile文件
以下是makefile全文:
#--------------------------------------------------------------------
CC = gcc
AR = ar cru
CFLAGS = -Wall -D_REENTRANT -D_GNU_SOURCE -g -fPIC
SOFLAGS = -shared
LDFLAGS = -lstdc++ -lpthread
LINKER = $(CC)
LINT = lint -c
RM = /bin/rm -f
LIBEVENT_INCL = -I$(HOME)/libevent/
LIBEVENT_LIB = -L$(HOME)/libevent -levent -lrt
CFLAGS += $(LIBEVENT_INCL)
LDFLAGS += $(LIBEVENT_LIB)
#--------------------------------------------------------------------
LIBOBJS = sputils.o spioutils.o spiochannel.o
spthreadpool.o event_msgqueue.o spbuffer.o sphandler.o
spmsgblock.o spmsgdecoder.o spresponse.o sprequest.o
spexecutor.o spsession.o speventcb.o spserver.o
spdispatcher.o splfserver.o
sphttpmsg.o sphttp.o spsmtp.o
TARGET = libspserver.so libspserver.a
testecho testthreadpool testsmtp testchat teststress testhttp
testhttp_d testhttpmsg testdispatcher testchat_d testunp
#--------------------------------------------------------------------
all: $(TARGET)
libspserver.so: $(LIBOBJS)
$(LINKER) $(SOFLAGS) $^ -o $@
libspserver.a: $(LIBOBJS)
$(AR) $@ $^
testthreadpool: testthreadpool.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
testsmtp: testsmtp.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
testchat: testchat.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
teststress: teststress.o
$(LINKER) $^ -L. -levent $(LDFLAGS) -o $@
testecho: testecho.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
testhttp: testhttp.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
testhttp_d: testhttp_d.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
testhttpmsg: sputils.o sphttpmsg.o testhttpmsg.o
$(LINKER) $^ $(LDFLAGS) -o $@
testdispatcher: testdispatcher.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
testchat_d: testchat_d.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
testunp: testunp.o
$(LINKER) $^ -L. -lspserver $(LDFLAGS) -o $@
clean:
@( $(RM) *.o vgcore.* core core.* $(TARGET) )
#--------------------------------------------------------------------
# make rule
%.o : %.c
$(CC) $(CFLAGS) -c $^ -o $@
%.o : %.cpp
$(CC) $(CFLAGS) -c $^ -o $@
|
如果CentOS支持multilib,那么在CFLAGS里加上-m32即可
|
先检测你的gcc,是否支持-m32
支持的话,CFLAGS = $(CFLAGS) -m32
不支持的话,要重新折腾个gcc了
|
CentOS 64位还得先装32位的运行时库吧