zoukankan      html  css  js  c++  java
  • C++静态库中使用_declspec(dllexport) 不能导出函数的问题

    在某项目中,有一些静态库,这些静态库中有类型命名的函数GET_XXX。在一次项目结构调整的时候,我想将调用这静态库的代码编译成DLL,并且将这些Get函数导出,我就直接就这些函数前面添加了_declspec(dllexport),

    然后代码结构就成为:

    静态库A: 包括很多 _declspec(dllexport) GET_XXX 函数。

    动态库B:未直接调用 GET_XXX

    调用B的应用程序C:动态Load动态库B,然后使用GetProcAddress获取函数地址后使用。

    但是很不幸编译出来的中一直没有这些函数。

       百思不得其解,最后在网上发现下面的信息(from:http://support.microsoft.com/kb/141459):

    When you build a DLL from component libraries (.lib files) that have functions declared with _declspec(dllexport) to export them from the DLL, the functions aren't exported or even included in the DLL.

    解决方案:

    1、DEF文件或者是在LInk时添加/export:func.

    2、在其它地方强引用。

    3、把GET等函数所在源码直接放到dll代码里编译。

    对于我的工程,1、2不适合,所以我使用了3.

    http://www.cnblogs.com/k1988/archive/2013/02/16/2913534.html

    http://www.cnblogs.com/k1988/p/3587820.html

  • 相关阅读:
    python——numpy模块
    python——xlrd、xlwt、xlutils模块
    python——json&pickle模块
    python——sys模块
    python——os模块
    python——random模块
    python——time模块
    linux命令 pwd
    linux 里面ls命令!!
    校花网图片爬取
  • 原文地址:https://www.cnblogs.com/findumars/p/5180464.html
Copyright © 2011-2022 走看看