• 8737阅读
  • 4回复

[提问]QLibrary load函数加载库函数错误 [复制链接]

上一主题 下一主题
离线gameboy374
 
只看楼主 倒序阅读 楼主  发表于: 2012-11-16
    QLibrary lib("EPCSDK.dll");    
    if(lib.load())
        cout<<"load successful"<<endl;
    else    {
        QMessageBox::information(this,"error","load error");
        qDebug()<<lib.errorString()<<endl;
              }
总是提示错误 "Cannot load library EPCSDK.dll: 找不到指定的模块。" 开始把dll文件放在debug目录下面出现错误,后来把dll文件拷贝到所有的目录下面还是出现错误,但是我把system32文件里面的任何一个dll文件放在debug目录下面可以load()成功,请问一下这是什么原因?
离线passion_wu
只看该作者 1楼 发表于: 2012-11-17
可能是库的问题吧
离线gameboy374
只看该作者 2楼 发表于: 2012-11-17
引用第1楼passion_wu于2012-11-17 14:17发表的  :
可能是库的问题吧

但是我在vc6.0与vs2010上重新编译之后还是不能加载……
离线roywillow

只看该作者 3楼 发表于: 2012-11-17
回 2楼(gameboy374) 的帖子
文档中有这么一段
The symbol must be exported as a C function from the library for resolve() to work. This means that the function must be wrapped in an extern "C" block if the library is compiled with a C++ compiler. On Windows, this also requires the use of a dllexport macro; see resolve() for the details of how this is done. For convenience, there is a static resolve() function which you can use if you just want to call a function in a library without explicitly loading the library first:
专业维修核潜艇,回收二手航母、二手航天飞机,大修核反应堆,拆洗导弹发动机更换机油,无人侦察机手动挡改自动,航天飞机保养换三滤,飞碟外太空年检 ,各型号导弹加装迎宾踏板,高空作业擦洗卫星表面除尘、打蜡及抛光,东风全系列巡航导弹。并提供原子对撞机。量大从优,有正规发票。
离线gameboy374
只看该作者 4楼 发表于: 2012-11-18
回 3楼(roywillow) 的帖子
#ifdef EPCSDK_EXPORTS
#define EPCSDK_API __declspec(dllexport)
#else
#define EPCSDK_API __declspec(dllimport)
#endif

extern "C" EPCSDK_API HANDLE __stdcall OpenComm(int portNo);    // COM 1-9. Return -1(INVALID_HANDLE_VALUE) if failed.
extern "C" EPCSDK_API HANDLE __stdcall Open(int portNo,int baundRate);    // COM 1-9. Return -1(INVALID_HANDLE_VALUE) if failed.
这是我头文件声明,所以不是关于extern "C"的问题…
快速回复
限100 字节
 
上一个 下一个