2016-04-29 20 views
-1

私はゲーム開発コースの摂取割り当てに取り組んでいますが、私のコードをクラスに分割した後、Visual Studioの迷惑なエラーに悩まされています。エラーはLNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" ([email protected]@YAHXZ)と表示されますので、私の主な機能に何か間違っているはずです。私は周りを見回し、最も論理的な理由は間違ったサブシステムと思われるが、それはコンソールアプリケーションに設定されている。解決されていない外部シンボル_mainが参照されました

MAIN.CPP:

#include <Box2D/Box2D.h> 
#include <SFML/Graphics.hpp> 

#include "Game.hpp" 

int main() { 
    Game game; //Sets up the game 

    game.populateWorld(); 

    while (game.window.isOpen()) { 
     game.checkEvents(); 

     game.drawBodies(); 

     game.m_Player->movePlayer(); 

    } 

    return 0; 
} 

Game.hpp:

#ifndef Game_hpp 
#define Game_hpp 

#include <SFML/Graphics.hpp> 
#include "World.hpp" 
#include "Player.hpp" 
class Game { 
public: 
    Game(); 
    void checkEvents(); 
    void drawBodies();//Displays the bodies and keeps the view centered 

    //Public data members to be used by other classes 
    sf::Texture backGroundTexture; 
    sf::Texture playerTex; 
    sf::Texture platformTex;//Doesn't have a sprite declared since multiple copy's will be made 
    sf::Sprite backGround; 
    sf::Sprite player; 
    sf::View view; 
    sf::RenderWindow window; 

    const float m_Scale;//Number of pixels per meter 

    Player* m_Player = NULL; 
    World* m_World = NULL; 
    void populateWorld(); 
private: 
    void loadResources();//Loads resources and applies them where needed 
}; 
#endif // !Game_hpp 

World.hpp:

#ifndef World_hpp 
#define World_hpp 

#include <Box2D/Box2D.h> 

class World { 
public: 
//Public member functions 
    World(const float scale); 
    ~World(); 
    void step(); 
    b2Body* spawnPlayer(float x, float y); 

//Public data members 
    b2World* world = NULL; //Points to the entire world! Handle with care ;) 

    void createPlatform(b2Vec2 point); 
private: 
//Private data members 
    b2Vec2 gravity; 
    const float m_Scale; 

    //Declaring step values 
    float32 m_TimeStep; 
    int32 m_VelocityIterators; 
    int32 m_PositionIterators; 
}; 

#endif // !World_hpp 

ここに私のコードですPlayer.hpp:

#ifndef Player_hpp 
#define Player_hpp 

#include <Box2D/Box2D.h> 

#include "World.hpp" 

class Player{ 

public: 
    Player(World* world, const float scale, float x, float y); 
    void movePlayer(); 
    b2Body* m_PlayerBody;//A pointer to the player Character's body needed  for the movement 
private: 
    World* m_World; 
    const float m_Scale; 
}; 

#endif // !Player_hpp 

ホープ誰もが間違って何が起こっているのかと正しい方向に私を指すことができます:)

+0

正しい方向は検索テキストボックスの方向です:http://stackoverflow.com/search?tab=relevance&q=unresolved%20external%20symbol%20_main – Drop

答えて

0

iはラインを使用してmain.cppにについての警告がありました...無知だったと思います私はiMacで働いているので、Mac OS Xのエンディングは気にしませんでした。しかし、私はメモ帳でこれを修正した場合、++ EDIT -> EOL Conversion -> Windows Format、それはシャムのように働いた!私がいたので

1)プロジェクトを閉じてPCに

2を再起動して)新しいプロジェクトを作成し、このスレッド以下:私の悪い私は、私は次のようで私の問題を解決しました^^

関連する問題