6

I have a static library which is build using /GR- (RTTI disabled), in CMake:

add_library(LibName STATIC someSource.cpp)
target_compile_options(LibName PRIVATE /GR-)
...

And my executable is build using /GR (RTTI enabled) and is depending on the library:

target_link_libraries(myTarget ${LibName})
target_compile_options(myTarget PRIVATE /GR)
...

When doing the same with GCC respectively using flags -fno-rtti & -frtti, you'll get linker errors like: undefined reference to typeinfo for ClassName. Why not for MSVC, do I need to be worried? Or is this a feature of MSVC?

jaques-sam
  • 2,578
  • 1
  • 26
  • 24
  • See the second answer to [Undefined reference to typeinfo](https://stackoverflow.com/questions/307352/g-undefined-reference-to-typeinfo). – 1201ProgramAlarm Jul 01 '19 at 18:29
  • @1201ProgramAlarm which answer do you mean? This doesn't answer my question. – jaques-sam Jul 02 '19 at 14:11
  • 2
    The problem is the GCC error, and the question I linked to addresses that problem. There is not an issue mixing RTTI and non-RTTI code. – 1201ProgramAlarm Jul 02 '19 at 20:33
  • After reviewing, it looks like that second answer is not the one we need because we don't have linker issues when compiling everything with RTTI. There is no function that is missing a body... The right answer is still: https://stackoverflow.com/a/4184877/2522849. Seems that GCC cannot handle it! – jaques-sam Jul 10 '19 at 14:37

0 Answers0