参考 http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
gcc -fPIC -g -c -Wall a.c gcc -fPIC -g -c -Wall b.c gcc -shared -Wl,-soname,libmystuff.so.1 \ -o libmystuff.so.1.0.1 a.o b.o –lc
makefile
CC = gcc
CXX = g++
DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES)
CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT -fPIC $(DEFINES)
INCPATH = -I../../../../x86/mkspecs/qws/linux-x86-g++ -I. -I../../../../x86/include/QtCore -I../../../../x86/include/QtNetwork
-I../../../../x86/include/QtGui -I../../../../x86/include -I. -I.
LINK = g++
LFLAGS = -Wl,-O1 -Wl,-rpath,/opt/qt-everywhere/x86/lib -shared -Wl,-soname,libclient.so.1
LIBS = $(SUBLIBS) -L/opt/qt-everywhere/x86/lib -lQtGui -L/opt/qt-everywhere/x86/lib -lQtNetwork -lQtCore –lpthread
####### Implicit rules
.SUFFIXES: .o .c .cpp .cc .cxx .C
.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.C.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
$(TARGET): $(OBJECTS)
-$(DEL_FILE) $(TARGET)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS) $(OBJCOMP)