所以我想用Qt作为我的SDL应用程序的编辑器。当我尝试在Qt中创建一个空白项目并链接库时,它无法找到SDL2 / SDL.h。这是我的.pro文件中的内容:
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"
我无法找到任何已发布如何使其发挥作用的人,但我知道必须有某种方式。它只需点击一下即可在Xcode中运行,所以我只是做错了吗?感谢。
编辑:
此处发出错误消息:
/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>
编辑:我已经得到它所以我可以包括但不是,这是一个问题,因为SDL混音器和SDL rtf都使用
答案 0 :(得分:4)
当路径中包含空格时,您应该使用双引号,例如:
INCLUDEPATH += "$$PWD/../Control Libraries/SDL2.framework/Versions/A/Headers"
除非你确实希望它们是单独的参数,例如:
mac: LIBS += "-F$$PWD/../Control Libraries/" -framework SDL2_mixer
问题编辑后:您有#include <SDL2/SDl.h>
。它似乎有错误的情况,应该是
#include <SDL2/SDL.h>
答案 1 :(得分:1)
编译器清楚错误:
../ SpudEngineEditor / main.cpp:3:10:致命错误:&#39; SDL2 / SDl.h&#39;找不到文件
你应该做的是替换这一行:
#include <SDL2/SDl.h>
使用:
#include <SDL2/SDL.h>
// ^, yes uppercase.
此外,对于具有空格的路径,您应该使用为此目的而建立的the corresponding quote qmake function,这也适用于内部的双引号。在所有情况下,双引号也可能有效,但如果有一个已建立,我个人更喜欢花哨的功能。 : - )
如果我不重复相同的路径,我也会建立一个辅助变量。
此外,我会编写一个qmake函数,虽然内联调用不需要使用真正的qmake函数,for循环,因为你重复同样的事情。因此,我会写这样的东西:
setSDLPaths() {
CONTROL_LIBRARIES_PATH = $$quote($$PWD/../Control Libraries/)
LIST = SDL2 SDL2_ttf SDL2_mixer
for(item, LIST) {
mac: LIBS += -F$$CONTROL_LIBRARIES_PATH -framework $$item
INCLUDEPATH += $$CONTROL_LIBRARIES_PATH/$${item}.framework/Versions/A/Headers
}
}
然后会大大简化您的代码,基本上是单行代码:
$$setSDLPaths()