[英]Linux - Why does my executable have libpthread as a shared library?
So basically I´d like to know why my executable has libpthread as a shared library whilst my code is not using any threading functions whatsoever. 因此,基本上我想知道为什么我的可执行文件将libpthread作为共享库,而我的代码却没有使用任何线程函数。 It isn´t included from the makefile either.
它也不包含在makefile中。 Is it because GCC is compiled by default with "--enable-threads=posix" ?
是因为GCC默认情况下是使用“ --enable-threads = posix”编译的?
If so is there a way to remove it from my executable? 如果是这样,有没有办法将其从我的可执行文件中删除? If not what is the problem?
如果不是,那是什么问题?
ldd dd
linux-vdso.so.1 => (0x0000656150c5a000)
librt.so.1 => /lib64/librt.so.1 (0x0000656150a4c000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x0000656150746000)
libm.so.6 => /lib64/libm.so.6 (0x00006561504c1000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00006561502ab000)
libc.so.6 => /lib64/libc.so.6 (0x000065614ff17000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x000065614fcf9000)
/lib64/ld-linux-x86-64.so.2 (0x0000656150c5b000)
Makefile 生成文件
CC = gcc
OFLAGS = -O3
C++ = g++ -g
LFLAGS = -lrt
# API Exclusions
DFLAGS = -DNO_ZLIB -DNO_LOCALIZATION -DNO_INTERFACE
CFLAGS = $(OFLAGS) $(DFLAGS) -I. -I../rgapi/include/core/ -I../rgapi/include/public/
OBJS = ( ... list of .o files ... )
PROGS = ./rgs
all: $(OBJS) $(PROGS)
./rgs: $(OBJS)
$(C++) -o ./rgs $(OBJS) $(LFLAGS)
clean:
rm -f $(OBJS) $(PROGS)
$(OBJS): %.o: %.cpp
$(C++) -o $@ $(CFLAGS) -c $<
./rgs: $(OBJS)
You are linking with librt.so
: 您正在与
librt.so
链接:
LFLAGS = -lrt
This is an indirect dependency. 这是间接依赖关系。
$ ldd /usr/lib64/librt.so
linux-vdso.so.1 (0x00007ffcc33d2000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f2480a0b000)
libc.so.6 => /lib64/libc.so.6 (0x00007f2480649000)
/lib64/ld-linux-x86-64.so.2 (0x0000562f4cffb000)
librt.so
is linked with -lpthread
. librt.so
与-lpthread
链接。 If you link with any shared library, you inherit all the baggage that the shared library gets linked with. 如果您与任何共享库链接,那么您将继承与共享库链接的所有行李。
You cannot "remove it from your executable". 您不能“将其从可执行文件中删除”。 The only way to do so is not link with
-lrt
. 唯一的方法不是与
-lrt
链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.