作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
将 CMake 下的 C++ 库移植到 Windows。
__declspec(dllexport)
修饰 API。设置(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
。我们选择选项 2,因为它看起来更容易,并且完整地保留了我们的资源。工作起来很神奇:我们的应用程序编译并与库 dll 链接。
但是,它只确保类和函数的导出。导出全局变量需要做什么?喜欢在:
lib_source.cpp:
int my_secret;
app.cpp:
extern int my_secret;
最佳答案
For global data symbols,
__declspec(dllimport)
must still be used when compiling against the code in the .dll.
来源:https://cmake.org/cmake/help/latest/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS.html
关于c++ - CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS 不覆盖全局变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54560832/
将 CMake 下的 C++ 库移植到 Windows。 选项 1:使用 __declspec(dllexport) 修饰 API。 选项 2:设置(CMAKE_WINDOWS_EXPORT_ALL_
我是一名优秀的程序员,十分优秀!