2014-11-05 78 views
1

我想在优胜美地上配置QTCreator和SFML,已经通过一个相当不愉快的问题,最小版本设置为OS X 10.6(现在它被设置为OS X 10.9 ),现在我遇到了“未定义符号的建筑x86_64的”的问题,下面是从QTCreator输出应用:QTCreator +优胜美地的SFML未定义的体系结构x86_64的符号

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 
+0

[vector :: push \ _back odr-使用该值,导致对静态类成员的未定义引用]的可能重复(http://stackoverflow.com/questions/272900/vectorpush-back-odr-uses-the- undefined-reference-to-static-clas) – Hiura 2014-11-05 07:47:18

+0

抱歉没有得到上述问题的关键,是不是与静态声明有关? – 2014-11-05 10:42:34

回答

0

我怀疑PlayMapAI::m_PlayMapAI是一个静态字段。这意味着你有一个翻译单元(的.cpp),可能PlayMapAI.cpp定义它,如下:

Type PlayMapAI::m_PlayMapAI; 
+0

对不起,花了这么长的时间来回复,刚刚更新了PlayMapAI代码,显然它不是......当我调用instance()方法时它崩溃了。 – 2014-11-10 20:09:22

+0

是的,就是这样。否则,你仍然会有相同的编译错误。现在你正面临另一个挑战。使用调试器,如果需要的话打开一个新的问题。 – Hiura 2014-11-10 20:19:32

+0

其实我仍然有着相同的编译错误,我不能在其他地方声明'PlayMapAI :: m_PlayMapAI;',因为它是私有的,它是通过instance()来访问的。对不起,打扰你,你能给我任何其他提示? – 2014-11-10 20:49:47

0

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

相关问题