Kobojunkie
Kobojunkie

Reputation: 6553

How to reference 3rd party dlls/libraries in Qt projects

Been trying to figure this out for an hour now. What I have is a simple Qt Project open in Qt Creator. What I would like to do is use the SDL library (dll) with my Qt project.

In visual Studio, what I would normall do is add a reference to this dll using VS tool that provides for that. In Qt creator, I opened the .pro file for my project, and added a LIB entry for the STD 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

However, that does not seem to include the Library in Qt for my use. When I compile, I still get an SDL.h: No such file or directory error message. Would appreciate any help in figuring this out and probably learning for the future as I intend to use Qt more often than not for my development work.

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

Upvotes: 1

Views: 2806

Answers (2)

Nikos C.
Nikos C.

Reputation: 51910

SDL.h is a C header file, not a library. For the compiler to find it, you need to add its directory to qmake's INCLUDEPATH. For example:

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

(Tip: you can use / instead of \ to stay clear of possible interpretations of \ as an escape character.)

Upvotes: 2

Violet Giraffe
Violet Giraffe

Reputation: 33605

Try something like:

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

Upvotes: 0

Related Questions