添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
直爽的小蝌蚪  ·  那英cp·  2 月前    · 
冷冷的单杠  ·  将 Kubernetes ...·  12 月前    · 
乖乖的书包  ·  北京师范大学文学院·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams
  • Option 1: Decorate the API with __declspec(dllexport) .
  • Option 2: set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) .
  • We go for option 2, since it seems much easier, and leaves our sources intact. Works like a charm: our application compiles and gets linked with the library dll.

    However, it ensures only the export of classes and functions. What needs to be done to export global variables? Like in:

    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.

    src: https://cmake.org/cmake/help/latest/prop_tgt/WINDOWS_EXPORT_ALL_SYMBOLS.html

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.