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

时间:2011-11-26 20:58:07

标签: c++ qt mingw sdl qt-creator

现在试图解决这个问题一个小时了。我所拥有的是在Qt Creator中打开的简单Qt项目。我想要做的是在我的Qt项目中使用SDL库(dll)。

在Visual Studio中,我要做的是使用提供该功能的VS工具添加对此dll的引用。在Qt创建者中,我为我的项目打开了.pro文件,并为STD dll添加了一个LIB条目

# 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中的库供我使用。编译时,我仍然收到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

2 个答案:

答案 0 :(得分:2)

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

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

(提示:您可以使用/而不是\来清除\作为转义字符的可能解释。)

答案 1 :(得分:0)

尝试类似:

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