2016-04-29 72 views
-1

我正在为游戏开发课程的摄入任务工作,但是我将视频工作室的烦人错误停留在将我的代码分解到课程后。错误状态LNK2019 unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" ([email protected]@YAHXZ)所以它应该是我的主要功能有问题。我环顾四周,最合乎逻辑的原因似乎是错误的子系统,但这是设置为控制台应用程序。这里是我的代码:无法解析的外部符号_main referenced

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

猜猜我是无知的方向是正确的......有一个关于使用的main.cpp行警告因为我在iMac上工作,所以我并不在意Mac OS X的结局。但是,当我在记事本++ EDIT -> EOL Conversion -> Windows Format中修复这个问题时,它的工作方式就像一个沙盘!

1)关闭该项目,并重新启动计算机

2)创建一个新的项目并按照这个线程,因为我:我的坏恐怕^^