On Fri, Aug 11, 2017 at 1:34 PM, Godmar Back godmar@gmail.com wrote:
Is this the wrong mailing list to ask the question then?
Perhaps, but maybe you will get a response on Monday from someone in Europe that didn't see it today.
Normally, libraries are decomposed into individual .o files to avoid exactly this phenomenon where an undefined reference to function X pulls in definitions of functions Y, Z, etc. which then cause a chain of dependencies to other .o files the linker must resolve. Is libstdc++ different in this respect? Because otherwise, features would only be pulled in if required, and that's a much more manageable problem.
Yes, of course, if you static link, then you only get the .o files that you need. But as I mentioned before, a lot of C++ features depend on other C++ features. A simple hello world program compiled and statically linked is over 2MB.
palantir:2089$ cat tmp.cc #include <iostream>
int main (void) { std::cout << "Hello world\n"; return 0; } palantir:2090$ g++ -static tmp.cc palantir:2091$ ls -lt a.out -rwxrwxr-x 1 wilson wilson 2181416 Aug 11 14:03 a.out palantir:2092$
We can see all of the object files being pulled in if we pass the --verbose option to the linker. There are 92 of them.
palantir:2092$ g++ -static tmp.cc -Wl,--verbose | grep libstdc attempt to open /usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a succeeded (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)ios_init.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)globals_io.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)ios-inst.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)ext11-inst.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)ostream-inst.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)wlocale-inst.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)ios.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)cow-wstring-inst.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)istream-inst.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)functexcept.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)cow-stdexcept.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)streambuf-inst.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)eh_throw.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)eh_exception.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)eh_personality.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)del_op.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)eh_catch.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)eh_aux_runtime.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)bad_typeid.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)bad_cast.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)si_class_type_info.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)eh_call.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)new_opv.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)pure.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)tinfo.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)class_type_info.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)new_op.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)new_handler.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)vmi_class_type_info.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)del_opv.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)eh_alloc.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)eh_terminate.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)eh_globals.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)bad_alloc.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)dyncast.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)locale.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)istream.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)locale_facets.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)time_members.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)locale_init.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)stdexcept.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)c++locale.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)monetary_members_cow.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)numeric_members.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)basic_file.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)ios_locale.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)streambuf.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)messages_members_cow.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)numeric_members_cow.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)codecvt.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)cow-istream-string.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)codecvt_members.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)collate_members_cow.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)ctype.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)string-inst.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)cxx11-locale-inst.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)locale-inst.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)cxx11-wlocale-inst.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)cow-string-inst.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)snprintf_lite.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)fstream-inst.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)cxx11-stdexcept.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)system_error.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)cow-shim_facets.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)cow-locale_init.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)ctype_configure_char.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)functional.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)ctype_members.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)cxx11-shim_facets.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)wstring-inst.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)future.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)regex.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)lt1-codecvt.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)cxx11-ios_failure.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)iostream-inst.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)compatibility.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)bad_array_new.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)guard.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)eh_unex_handler.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)eh_ptr.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)eh_term_handler.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)monetary_members.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)misc-inst.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)istream-string.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)collate_members.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)messages_members.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)futex.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)condition_variable.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)guard_error.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)vterminate.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)eh_type.o (/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a)cp-demangle.o palantir:2093$
Perhaps there are other things that can be used that have smaller requirements, but in general, the C++ library is not designed for small slices. Everything depends on everything else, and it is best to use shared linking and use the whole thing as a single unit.
Jim