简体   繁体   English

Qt:库的静态链接

[英]Qt: Static linking of libraries

I'm developing a Qt application in windows. 我正在Windows中开发Qt应用程序。 I have created a lib file in visual studio. 我已经在Visual Studio中创建了一个lib文件。 I have included the header file containing function prototypes in my Qt App and also added lib file in .pro file as follows 我已经在Qt App中包含了包含函数原型的头文件,并且还在.pro文件中添加了lib文件,如下所示

        win32: LIBS += -L$$PWD/../Lib/ -lCpLib
        INCLUDEPATH += $$PWD/../Lib
        DEPENDPATH += $$PWD/../Lib
        win32: PRE_TARGETDEPS += $$PWD/../Lib/CpLib.lib

I called the functions from my Qt app. 我从Qt应用程序调用了这些函数。 It shows compile error as "undefined reference" Please help me. 它显示编译错误为“未定义的引用”,请帮助我。

Regards.... 问候....

The specification of your LIBS is passing linker arguments in gcc format (ie using -L to specify the directory and -l to specify the library name). 您的LIBS规范正在以gcc格式传递链接器参数(即,使用-L指定目录,使用-l指定库名)。

As you have created your lib file in Visual Studio, you'll need to specify the full library name 在Visual Studio中创建lib文件后,您需要指定完整的库名

eg 例如

win32: LIBS += yourlibrary.lib

alternatively, recompile the libraries using MinGW 或者,使用MinGW重新编译库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM