Yosemite上的QTCreator + SFML架构x86_64的未定义符号

时间:2014-11-05 01:29:32

标签: qt-creator sfml

我正在尝试在Yosemite上配置QTCreator和SFML,已经经历了一个相当令人不快的问题,将最小版本设置为OS X 10.6(现在它设置为OS X 10.9),现在我遇到了问题'架构x86_64'的未定义符号,这里是QTCreator的应用程序输出:

Undefined symbols for architecture x86_64:
  "PlayMapAI::m_PlayMapAI", referenced from:
      PlayMapAI::instance() in MenuState.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [framework] Error 1
23:23:14: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project framework (kit: Desktop Qt 5.3 clang 64bit)
When executing step "Make"

以下是它运行的选项:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -std=c++11 -Wno-ignored-qualifiers -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -mmacosx-version-min=10.9 -Wall -W -fPIE  -I/Applications/QT/5.3/clang_64/mkspecs/macx-clang -I../qtcreator -I../../include -I../../include/tinyxml -I../../include/tmxloader -I/usr/local/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -o PlayState.o ../../source/PlayState.cpp

任何提示?

- 更新

这是PlayMapAI.h文件(没有任何.cpp文件):

#ifndef PLAY_MAPAI_H_
#define PLAY_MAPAI_H_

#include <list>
#include <string>
#include "GameState.h"
#include "Sprite.h"
#include "InputManager.h"
#include <MapLoader.h>

struct Kinematic
{
    cgf::Sprite* sprite;
    sf::Vector3f pos;
    sf::Vector3f vel;
    sf::Vector3f heading;
    float maxForce;
    float maxSpeed;
    float maxTurnRate;
};

class PlayMapAI : public cgf::GameState
{
public:

    void init();
    void cleanup();

    void pause();
    void resume();

    void handleEvents(cgf::Game* game);
    void update(cgf::Game* game);
    void draw(cgf::Game* game);

    // Implement Singleton Pattern
    static PlayMapAI* instance()
    {
        return &m_PlayMapAI;
    }

protected:

    PlayMapAI() {}

private:

    static PlayMapAI m_PlayMapAI;

    int x, y;
    float speed; // player speed
    float zvel;
    cgf::Sprite player;
    cgf::Sprite ghost;

    sf::RenderWindow* screen;

    std::list<sf::Vector3f> trail;
    bool showTrails;

    Kinematic playerK, enemyK;
    cgf::InputManager* im;
    sf::Font font;
    sf::Text text;
    tmx::MapLoader* map;
    bool firstTime;

    bool checkCollision(uint8_t layer, cgf::Game* game, Kinematic& obj);
    void centerMapOnPlayer();
    sf::Uint16 getCellFromMap(uint8_t layernum, float x, float y);

    enum {
         CHASE_BEHAVIOR=0, ARRIVE_BEHAVIOR, PURSUIT_BEHAVIOR, FLEE_BEHAVIOR, EVADE_BEHAVIOR
    };

    const static std::string modes[];

    int steerMode;
    sf::Vector3f chase(Kinematic& vehicle, sf::Vector3f& target); // ir diretamente ao jogador
    sf::Vector3f arrive(Kinematic& vehicle, sf::Vector3f& target, float decel=0.2); // ir diretamente ao jogador
    sf::Vector3f pursuit(Kinematic& vehicle, Kinematic& target); // perseguir o jogador, prevendo a posição futura
    sf::Vector3f flee(Kinematic& vehicle, sf::Vector3f& target, float panicDistance=100);  // fugir do jogador
    sf::Vector3f evade(Kinematic& vehicle, Kinematic& target);
};

#endif

2 个答案:

答案 0 :(得分:0)

我怀疑PlayMapAI::m_PlayMapAI是一个静态字段。这意味着您必须在翻译单元(.cpp)中定义它,可能是PlayMapAI.cpp,如下所示:

Type PlayMapAI::m_PlayMapAI;

答案 1 :(得分:0)

如果您使用的是任何c ++ 11功能,则必须在.pro文件中包含CONFIG += c++11。还要确保您的编译器具有正确版本的SFML。还要确保QT是最新的。