2

I compiled the same program (not library) with different compilation flags, in CMake with Clang

  1. with CMAKE_C_FLAGS = -Wl,-export-dynamic
  2. with CMAKE_EXE_LINKER_FLAGS = -export-dynamic

But I noticed that the second way doesn't seem to work. I can't find the exported symbols. I'm so surprised that only the 1st way works. I don't know if the C compilers do something tricky, or Clang, or CMake. But how to let the second way work? The first way would print a lot of warnings.

ekd123
  • 525
  • 7
  • 19

1 Answers1

4

Provide same options for second variant.

set(CMAKE_EXE_LINKER_FLAGS "-Wl,-export-dynamic")

Because compiler and linker the same in your case.

Sergei Nikulov
  • 5,029
  • 23
  • 36