如何在Qt项目中引用第三方dll /库

问题描述:

一直试图找出一个小时。我拥有的是一个在Qt Creator中打开的简单Qt项目。我想要做的是在我的Qt项目中使用SDL库(dll)。如何在Qt项目中引用第三方dll /库

在Visual Studio中,我会正常做的是使用VS工具为此dll添加对此dll的引用。 Qt Creator中,我打开.pro文件为我的项目,并增加了对性病的dll

# Add more folders to ship with the application, here 
folder_01.source = qml/BoxGame 
folder_01.target = qml 
DEPLOYMENTFOLDERS = folder_01 

# Additional import path used to resolve QML modules in Creator's code model 
QML_IMPORT_PATH = 

symbian:TARGET.UID3 = 0xEED812B5 

# Smart Installer package's UID 
# This UID is from the protected range and therefore the package will 
# fail to install if self-signed. By default qmake uses the unprotected 
# range value if unprotected UID is defined for the application and 
# 0x2002CCCF value if protected UID is given to the application 
#symbian:DEPLOYMENT.installer_header = 0x2002CCCF 

# Allow network access on Symbian 
symbian:TARGET.CAPABILITY += NetworkServices 

# If your application uses the Qt Mobility libraries, uncomment the following 
# lines and add the respective components to the MOBILITY variable. 
# CONFIG += mobility 
# MOBILITY += 
LIBS += C:\Users\vata\Desktop\DskProj\Dsk-build-desktop\debug\SDL.dll 


# The .cpp file which was generated for your project. Feel free to hack it. 
SOURCES += main.cpp \ 
    blockboxes.cpp \ 
    block.cpp \ 
    boxengine.cpp \ 
    boxgame.cpp \ 
    point.cpp \ 
    gamecontroller.cpp \ 
    gamecontrollermod.cpp 

# Please do not modify the following two lines. Required for deployment. 
include(qmlapplicationviewer/qmlapplicationviewer.pri) 
qtcAddDeployment() 

HEADERS += \ 
    blockboxes.h \ 
    block.h \ 
    boxengine.h \ 
    boxgame.h \ 
    Globals.h \ 
    point.h \ 
    gamecontroller.h \ 
    gamecontrollermod.h \ 
    controller.h 

然而,这似乎并没有包含在Qt的图书馆为我用一个LIB条目。当我编译时,我仍然收到SDL.h: No such file or directory错误消息。希望得到任何帮助以解决这个问题,并可能为未来学习,因为我打算在开发工作中经常使用Qt。

Running build steps for project Tetris... 
Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe" clean 
C:/QtSDK/mingw/bin/mingw32-make -f Makefile.Debug clean 

试着这么做:

LIBS += -LC:\\Users\\vata\\Desktop\\DskProj\\Dsk-build-desktop\\debug -lsdl

+0

刚刚测试过,并没有奏效。 – Kobojunkie

+1

@Kobojunkie:尝试'LIBS + =“C:/Users/vata/Desktop/DskProj/Dsk-build-desktop/debug/SDL.dll”' –

+0

这也行不通。 – Kobojunkie

SDL.h是一个C头文件,而不是库。为了让编译器找到它,你需要将它的目录添加到qmake的INCLUDEPATH中。例如:

INCLUDEPATH += C:/Dir/Where/SDL/Headers/Are/Found

(提示:你可以使用/,而不是\独善其身\可能解释为转义字符的)。