Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking SDL2 in QtCreator

Tags:

c++

macos

qt

sdl

qmake

So I want to use Qt as an editor for my SDL app. When I try to make even just a blank project in Qt and link up the libraries, it just can't find SDL2/SDL.h. Here is whats inside my .pro file:

mac: LIBS += "-F$$PWD/../Control Libraries/" -framework SDL2
INCLUDEPATH += "$$PWD/../Control Libraries/SDL2.framework/Versions/A/Headers"


mac: LIBS += "-F$$PWD/../Control Libraries/" -framework SDL2_mixer
INCLUDEPATH += "$$PWD/../Control Libraries/SDL2_mixer.framework/Versions/A/Headers"


mac: LIBS += "-F$$PWD/../Control Libraries/" -framework SDL2_ttf
INCLUDEPATH += "$$PWD/../Control Libraries/SDL2_ttf.framework/Versions/A/Headers"

I can't find anyone who has posted how to get this to work, but I know there has to be some way. It works in Xcode with one click, so am I just doing something wrong? Thanks.

EDIT:

Here iss the error message:

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.6 -Wall -W -fPIE -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../Qt/5.3/clang_64/mkspecs/macx-clang -I../SpudEngineEditor -I../Control\ Libraries/SDL2.framework/Headers -I../Control\ Libraries/SDL2_mixer.framework/Headers -I../Control\ Libraries/SDL2_ttf.framework/Headers -I../../../Qt/5.3/clang_64/lib/QtWidgets.framework/Versions/5/Headers -I../../../Qt/5.3/clang_64/lib/QtGui.framework/Versions/5/Headers -I../../../Qt/5.3/clang_64/lib/QtCore.framework/Versions/5/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I. -F/Users/Logan/Qt/5.3/clang_64/lib -o Camera.o ../SpudEngineEditor/Camera.cpp
In file included from ../SpudEngineEditor/Camera.cpp:9:
In file included from ../SpudEngineEditor/Camera.h:13:
../SpudEngineEditor/CoreEngine.h:14:9: warning: unknown pragma ignored [-Wunknown-pragmas]
#pragma comment (lib, "glu32.lib")
        ^
In file included from ../SpudEngineEditor/Camera.cpp:9:
In file included from ../SpudEngineEditor/Camera.h:13:
In file included from ../SpudEngineEditor/CoreEngine.h:34:
../Control Libraries/SDL2_ttf.framework/Headers/SDL_ttf.h:30:10: fatal error: 'SDL2/SDL.h' file not found
#include <SDL2/SDL.h>

EDIT: I've gotten it so I can include , but not , which is a problem because SDL mixer and SDL rtf both use

like image 268
BlueSpud Avatar asked Feb 26 '26 17:02

BlueSpud


1 Answers

You should use double quotes when paths have spaces in them, for example:

INCLUDEPATH += "$$PWD/../Control Libraries/SDL2.framework/Versions/A/Headers"

Unless you do want them to be separate arguments, for example:

mac: LIBS += "-F$$PWD/../Control Libraries/" -framework SDL2_mixer

After question edit: So you have #include <SDL2/SDl.h>. It seems to have wrong case, should probably be

#include <SDL2/SDL.h>
like image 200
hyde Avatar answered Mar 01 '26 10:03

hyde



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!