1

I'm trying to configure QTCreator and SFML on Yosemite, have already gone through a rather unpleasant problem with min version set to OS X 10.6 (now it is set to OS X 10.9), now I'm having problem with 'Undefined symbols for architecture x86_64', here's the application output from 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"

and here are the options it ran with:

/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

Any tips?

-- Update

Here's the PlayMapAI.h file (don't have any .cpp file):

#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
C. Porto
  • 631
  • 3
  • 12
  • 26
  • possible duplicate of [vector::push\_back odr-uses the value, causing undefined reference to static class member](http://stackoverflow.com/questions/272900/vectorpush-back-odr-uses-the-value-causing-undefined-reference-to-static-clas) – Hiura Nov 05 '14 at 07:47
  • Sorry didn't get the point of the above question, isn't it related to static declaration? – C. Porto Nov 05 '14 at 10:42

2 Answers2

0

I suspect that PlayMapAI::m_PlayMapAI is a static field. This means you have to define it in a translation unit (.cpp), probably PlayMapAI.cpp, as follow:

Type PlayMapAI::m_PlayMapAI;
Hiura
  • 3,500
  • 2
  • 20
  • 39
  • Sorry for taking so long to respond, just updated with PlayMapAI code, apparently it is not that... it crashes when I call the instance() method. – C. Porto Nov 10 '14 at 20:09
  • Yes, it is that. Otherwise you would still have the same compilation error. Now you are facing another challenge. Use a debugger and if needed open a new question. – Hiura Nov 10 '14 at 20:19
  • Actually I'm still with the same compilation error, and I can't declare in any other place `PlayMapAI::m_PlayMapAI;` because it is private and it is being accessed through instance(). Sorry to bother you with this, can you give me any other tips? – C. Porto Nov 10 '14 at 20:49
  • Did you forget `PlayMapAI::` when declaring your `instance` function? – Hiura Nov 10 '14 at 21:54
  • When I call instance I do it like this `PlayMapAI::instance()` since it's a singleton, as for declaring it is like this `static PlayMapAI* instance()` inside the function, it returns `m_PlayMapAI` which is a private & static attribute. This is described in my question if you would like to give a look, I just updated with the code. – C. Porto Nov 10 '14 at 22:02
  • I didn't meant when you call it but when you implement it. – Hiura Nov 11 '14 at 06:33
0

If you are using any c++ 11 features, you must have CONFIG += c++11 in your .pro file. Also make sure you have the correct version of SFML for your compiler.Also make sure QT is up to date.

Devilswin
  • 11
  • 2