cflags '-Wl,-export-dynamic' vs linker fla

2019-07-21 09:07发布

问题:

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.

回答1:

Provide same options for second variant.

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

Because compiler and linker the same in your case.



标签: c cmake clang