当前位置: 技术问答>linux和unix
动态库编译 -static 选项没效果?
来源: 互联网 发布时间:2017-04-22
本文导语: 编译出来看到还是大小那么大,依赖的库也没变。是哪儿错了? CC = g++ RELEASE = 1 UNICODE = 0 LIB = -static -lrt -ldl -lpthread LIBINCLUDE = NetEngine_PermissionsSystem.o Algorithm_DllMain.o Algorithm_String.o ifeq ($(RELEASE),1) FLAGS = -c -O2 D...
编译出来看到还是大小那么大,依赖的库也没变。是哪儿错了?
CC = g++
RELEASE = 1
UNICODE = 0
LIB = -static -lrt -ldl -lpthread
LIBINCLUDE = NetEngine_PermissionsSystem.o Algorithm_DllMain.o Algorithm_String.o
ifeq ($(RELEASE),1)
FLAGS = -c -O2
DEBUG =
else
FLAGS = -c -lc_p
DEBUG = -g -pg
endif
ifeq ($(UNICODE),1)
UNICODE = -D _UNICODE
else
UNICODE =
endif
all:$(LIBINCLUDE)
$(CC) $(DEBUG) $(LIBINCLUDE) -o libNetEngine_Algorithm.so -shared -fPIC $(LIB)
NetEngine_PermissionsSystem.o:./NetEngine_PermissionsSystem/NetEngine_PermissionsSystem.cpp
$(CC) $(FLAGS) $(UNICODE) ./NetEngine_PermissionsSystem/NetEngine_PermissionsSystem.cpp
Algorithm_String.o:./Algorithm_String/Algorithm_String.cpp
$(CC) $(FLAGS) $(UNICODE) ./Algorithm_String/Algorithm_String.cpp
Algorithm_DllMain.o:./Algorithm_DllMain.cpp
$(CC) $(FLAGS) $(UNICODE) ./Algorithm_DllMain.cpp
|
If, instead, you use the GCC driver to create shared libraries, you may find that they will not always be linked with the shared libgcc. If GCC finds, at its configuration time, that you have a non-GNU linker or a GNU linker that does not support option --eh-frame-hdr, it will link the shared version of libgcc into shared libraries by default.
man gcc,-static-libgcc参数里面有这一段话,或许是这个原因
man gcc,-static-libgcc参数里面有这一段话,或许是这个原因