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

2019-07-21 08:34发布

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.

标签: c cmake clang
1条回答
Rolldiameter
2楼-- · 2019-07-21 09:32

Provide same options for second variant.

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

Because compiler and linker the same in your case.

查看更多
登录 后发表回答