2

Qt で SDL プロジェクトをコンパイルしたいと考えています。SDL フレームワーク 1.2.15 をダウンロードしました。Qt プロジェクト ファイルは次のとおりです。

TEMPLATE = app
SOURCES += main.cpp
OBJECTIVE_HEADERS += SDLMain.h
OBJECTIVE_SOURCES += SDLMain.m
LIBS += -framework Cocoa
LIBS += -F/Library/Frameworks
LIBS += -framework SDL

Qt 5.0.2 でコンパイルすると問題なく動作しますが、Qt 5.1.0 を使用すると SDLMain.m をコンパイルすると次のエラーが発生します。

error: 'SDL/SDL.h' file not found

Qt 5.1 が Qt 5.0.2 と同じ方法でフレームワークを処理しないのはなぜですか?

4

1 に答える 1

2

以前に機能していた理由はわかりませんが、次の点に注意してください。

  1. フレームワークを に追加すると、LIBSコンパイルではなく、リンクのみが処理されます。

  2. は必要ありません。必要ありませんINCLUDEPATH

  3. リンカーとコンパイラの両方のフレームワーク パスを追加する必要があります。

    // The directory where some frameworks are installed. There must
    // exist SDL.framework as a subdirectory of that directory.
    // It's simply to avoid typing the path twice.
    // It's a user variable, not interpreted by qmake
    SDL = -F/Library/Frameworks
    // Let the C/C++ compiler know where to find the frameworks.
    // This is so that when you include <xyz/foo>, it'll be replaced
    // by $$SDL/xyz.framework/Headers/foo
    // $$var is replaced by qmake by the contents of var
    QMAKE_CFLAGS += $$SDL
    QMAKE_CXXFLAGS += $$SDL
    // Since we compile some Objective C code, we need to set
    // the flags there too.
    QMAKE_OBJECTIVE_CFLAGS += $$SDL
    QMAKE_OBJECTIVE_CXXFLAGS += $$SDL
    // Let the linker know where to find the frameworks
    LIBS += $$SDL
    // Tell the linker that we want to use the SDL framework.
    LIBS += -framework SDL
    

これは、OS X 10.6 と 10.8 の両方でテストされています。xcode がインストールされていること、およびそれが特定の OS X で利用可能な最新バージョンであることを確認してください。

#include <SDL/SDL.h>

あなたのソースで。

于 2013-09-13T06:38:45.703 に答える