cflags' -Wl,-export-dynamic'vs链接器标记' -export-dynamic' [英] cflags '-Wl,-export-dynamic' vs linker flags '-export-dynamic'
问题描述
我在带有Clang的CMake中用不同的编译标志编译了相同的程序(不是库)
I compiled the same program (not library) with different compilation flags, in CMake with Clang
- with CMAKE_C_FLAGS = -Wl,-export-dynamic
- 使用CMAKE_EXE_LINKER_FLAGS = -export-dynamic
但是我注意到第二种方法似乎不起作用.我找不到导出的符号.我很惊讶只有第一种方法有效.我不知道C编译器是否执行棘手的操作,Clang或CMake.但是,如何让第二种方式起作用?第一种方法会打印很多警告.
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.
推荐答案
为第二个变体提供相同的选项.
Provide same options for second variant.
设置(CMAKE_EXE_LINKER_FLAGS"-Wl,-export-dynamic")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-export-dynamic")
因为在您的情况下,编译器和链接器相同.
Because compiler and linker the same in your case.
这篇关于cflags' -Wl,-export-dynamic'vs链接器标记' -export-dynamic'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!