How can I change the following static linked program into dynamic linked program?

时光毁灭记忆、已成空白 提交于 2020-12-14 23:48:40

问题


I have already figure out how to staticly link v8 with my own GLIBC/STDC++.

$(GCC_ROOT)/bin/g++ samples/bench.cpp -o bench -isystem$(GLIBC_ROOT)/include/ -I. -Iinclude -isystem$(GLIBC) -nodefaultlibs  -DV8_COMPRESS_POINTERS -static $(V8_OBJ)/libv8_monolith.a -Wl,--start-group $(GCC_ROOT)/lib64/libstdc++.a  $(GLIBC_ROOT)/lib/libpthread.a $(GLIBC_ROOT)/lib/libdl.a $(GLIBC_ROOT)/lib/libm.a $(GLIBC_ROOT)/lib/librt.a $(GCC_GCC)/libgcc.a $(GCC_GCC)/libgcc_eh.a $(GCC_GCC)/libcommon.a $(GLIBC_ROOT)/lib/libc.a -Wl,--end-group 

However, I find it not good to link all stuff staticly, and I want to GLIBC/STDC++ dynamicly, and my strategy is:

  1. For all .a which is staticly linked, I use -Wl,-rpath= to specify its path.
  2. For those .a which has no corresponding .so, such as libgcc.a, I still link them staticly.

So I write the following command

$(GCC_ROOT)/bin/g++ samples/bench.cpp -isystem$(GLIBC_ROOT)/include/ -I. -Iinclude -isystem$(GLIBC_ROOT)/ -o bench_dyn -nodefaultlibs  -DV8_COMPRESS_POINTERS -Wl,--start-group $(V8_OBJ)/libv8_monolith.a  -Wl,-rpath=$(GCC_ROOT)/lib64/ $(GCC_GCC)/libgcc.a $(GCC_GCC)/libgcc_eh.a $(GCC_GCC)/libcommon.a -Wl,-rpath=$(GLIBC_ROOT)/lib -Wl,--end-group 

However, this strategy won't work, because lots of symbols are not found, such as

  1. pthread_mutex_*
  2. std::ostream::operator<<(int)

I think these are all GLIBC/STDC++ symbols, and I linked them dynamicly, so they should not remain undefined?

What's wrong here?

来源:https://stackoverflow.com/questions/65217530/how-can-i-change-the-following-static-linked-program-into-dynamic-linked-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!