force visual studio to link all symbols in a lib file

后端 未结 6 1536
清酒与你
清酒与你 2020-12-09 16:19

Is there any way to force visual studio to link all symbols from a lib file into the dll as atm it is optimizing \"unused\" functions which are needed by the program using t

6条回答
  •  不思量自难忘°
    2020-12-09 16:44

    I had the same problem with a plugin system where factories in various DLLs were using a common main factory, everything registering at startup when loading libraries, without having to hard compile the list of plugins to use. This was working very well under Linux but had two problems under Windows:

    1. factories were not common between DLLs. This is not your problem but it is related. I got a solution here: Ensuring to use common fatories. Look at the answer by James with the set_the_global function.
    2. they were not setup at startup if no symbol of the DLL were used in the main. I think it is your problem. The only solution I found were to use configuration files (one by subproject) listing the names of the plugins (DLLs) available and force their linking using, in my case, QLibrary. Using cmake, a default version of a configuration file for each subproject is generated at build time using the following macro, called instead of add_library in each plugin dir:

      file(WRITE ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}-plugins "")
      macro (DECLARE_AMOSE_PLUGIN _plugin)
        file (APPEND ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}-plugins "${_plugin}\n")
        add_library(${_plugin} SHARED ${${_plugin}_LIB_SRCS})
      endmacro (DECLARE_AMOSE_PLUGIN)
      

提交回复
热议问题