Jan Deinhard
Jan Deinhard

Reputation: 20205

How to prevent specific symbols from being stripped out by the compiler/linker?

I have a C++ library containing several classes. Some of these classes are used explicitly by an executable and some are not. It seems clang and gcc strip classes not used explicitly from the executable.

How to prevent the compiler/linker from stripping specific symbols? Is there a pragma something similar available.

Upvotes: 3

Views: 1548

Answers (1)

artursg
artursg

Reputation: 66

For GCC try disabling DCE flags:

  • -fno-dce
  • -fno-dse
  • -fno-tree-dce
  • -fno-tree-dse

Upvotes: 1

Related Questions