Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 CMake 中使用 Clang 编译了具有不同编译标志的相同程序(不是库)
但我注意到第二种方法似乎不起作用。我找不到导出的符号。我很惊讶只有第一种方式有效。我不知道 C 编译器是否会做一些棘手的事情,或者 Clang 或 CMake。但是如何让第二种方式起作用呢?第一种方法会打印很多警告。
为第二个变体提供相同的选项。
设置(CMAKE_EXE_LINKER_FLAGS“-Wl,-导出-动态”)
因为在您的情况下编译器和链接器相同。