当前位置: 代码迷 >> QT开发 >> qt调用vc的dll的有关问题
  详细解决方案

qt调用vc的dll的有关问题

热度:267   发布时间:2016-04-25 05:10:22.0
qt调用vc的dll的问题
要在qt中调用vc生成的动态链接库test.dll。
在pro文件中已经加入了如下语句:

win32: LIBS += -L$$PWD/ -ltest

INCLUDEPATH += $$PWD/
DEPENDPATH += $$PWD/

在编译过程中出现如下错误:
main.cpp:14: 错误:undefined reference to `_imp___Z14Test'
Test中dll中的函数

想问一下,在qt中如果想直接调用vc的dll,应该如何操作?谢谢!

------解决方案--------------------
使用QLibrary
------解决方案--------------------
http://www.qtcn.org/bbs/read.php?tid=21009
楼主你看看这篇文章 你就豁然开朗了
------解决方案--------------------
最省事得办法:把Qt当做插件安装在VS200X上,用vs200X来编译
------解决方案--------------------
看了下文档,确实需要extern "C"。
void * QLibrary::resolve ( const char * symbol )

Returns the address of the exported symbol symbol. The library is loaded if necessary. The function returns 0 if the symbol could not be resolved or if the library could not be loaded.

Example:
C/C++ code
 typedef int (*AvgFunction)(int, int); AvgFunction avg = (AvgFunction) library->resolve("avg"); if (avg)     return avg(5, 8); else     return -1;
  相关解决方案