日期:2014-05-16  浏览次数:20710 次

如何在Linux编译32位库
大家好!
        我现在有一个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   $@