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:
- For all .a which is staticly linked, I use
-Wl,-rpath=
to specify its path. - 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
pthread_mutex_*
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?