It appears there are at least two ways to get the linker to include foo_impl::bar()
functionality in the executable:
- With gcc, one can use
-Wl,--whole-archive
to link an entire static library - no matter what. - As Captain Obvlious pointed out, when
foo_impl
is used in the program, it's virtual functions are tagged as having been used and are thus included in the executable. This could also be an otherwise useless static dummyfoo_impl
object.