Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Entry point must be defined  (Read 5915 times)

0 Members and 2 Guests are viewing this topic.

TheDianamu

  • Newbie
  • *
  • Posts: 20
    • View Profile
Entry point must be defined
« on: October 11, 2013, 02:25:20 pm »
Hi, I'm having troubles setting up:

I get  LINK : fatal error LNK1561: entry point must be defined with this code

#include "LEngine.h"
#include <SFML\Graphics.hpp>

void LEngine::Sprites(){
        sf::Texture t_grass;
        sf::Texture t_stone;
        sf::Texture t_water;

        t_grass.loadFromFile("grass.png");
        t_stone.loadFromFile("stone.png");
        t_water.loadFromFile("water.png");

        sf::Sprite grass;
        sf::Sprite stone;
        sf::Sprite water;

        grass.setTexture(t_grass);
        stone.setTexture(t_stone);
        water.setTexture(t_water);
}

void LEngine::Map(){
}

bool LEngine::Init(){
        window = new sf::RenderWindow(sf::VideoMode(800, 600, 32), "RPG");

        if(!window)
                return false;

        return true;
}

void LEngine::Events(){
        sf::Event evt;
        //Loop through all window events
        while(window->pollEvent(evt)){
                if(evt.type == sf::Event::Closed)
                        window->close();
        }
}

void LEngine::MainLoop(){
        while(window->isOpen()){
                Sprites();
                Map();
        }
}

void LEngine::boot(){
        if(!Init())
                throw "Could not initialize Engine";

        MainLoop();
}

TheDianamu

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Entry point must be defined
« Reply #1 on: October 11, 2013, 02:26:48 pm »
I've tried google, I've try almost everything, but I cannot get it work.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Entry point must be defined
« Reply #2 on: October 11, 2013, 02:33:46 pm »
Where is you int main() { }?
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Entry point must be defined
« Reply #3 on: October 11, 2013, 02:37:20 pm »
I've tried google, I've try almost everything, but I cannot get it work.
How is this possible, when searching for the error message yields tons of useful results?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

TheDianamu

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Entry point must be defined
« Reply #4 on: October 11, 2013, 02:38:01 pm »
Where is you int main() { }?

Opps, I forgot to make that xD

TheDianamu

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Entry point must be defined
« Reply #5 on: October 11, 2013, 02:40:09 pm »
Also what does

First-chance exception at 0x103159da (msvcr100d.dll) in Game.exe: 0xC0000005: Access violation reading location 0xccccccc0.
Unhandled exception at 0x103159da (msvcr100d.dll) in Game.exe: 0xC0000005: Access violation reading location 0xccccccc0.
 

mean? Using the same code as before

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Entry point must be defined
« Reply #6 on: October 11, 2013, 02:44:57 pm »
Step through the code with the debugger and find out where it crashes.

By the way, LEngine::Sprites() is completely meaningless. Take a look at the variable scopes...

window = new sf::RenderWindow(sf::VideoMode(800, 600, 32), "RPG");

    if(!window)
        return false;

    return true;
This code is questionable, too. First, you should never use new with raw pointers. Use automatic variables (sf::RenderWindow instead of sf::RenderWindow*), or -- if really necessary -- smart pointers. Second, the new operator does never return a null pointer. Third, the statement could be simplified to return window; or return window != nullptr (but as mentioned, it's useless anyway).
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

TheDianamu

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Entry point must be defined
« Reply #7 on: October 11, 2013, 02:45:52 pm »
I have sf::RenderWindow* window; in the header file.

It also stops the startup at : 'Game.exe': Loaded 'C:\WINDOWS\system32\imagehlp.dll', Cannot find or open the PDB file

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Entry point must be defined
« Reply #8 on: October 11, 2013, 02:46:52 pm »
I have sf::RenderWindow* window; in the header file.
That's what I mean: Just use
sf::RenderWindow window;

Or do you want to reduce compile-time dependencies (Pimpl idiom)?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

TheDianamu

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Entry point must be defined
« Reply #9 on: October 11, 2013, 02:48:22 pm »
I have sf::RenderWindow* window; in the header file.
That's what I mean: Just use
sf::RenderWindow window;

Or do you want to reduce compile-time dependencies (Pimpl idiom)?

What do you mean by "reduce compile-time dependencies"?

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Entry point must be defined
« Reply #10 on: October 11, 2013, 02:50:57 pm »
Apparently header dependencies are not your concern, so it's fine to use
sf::RenderWindow window;
instead of
sf::RenderWindow* window;

If you're interested in what I meant (it's not relevant for your problem), just search for the Pimpl idiom I mentioned before.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

TheDianamu

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Entry point must be defined
« Reply #11 on: October 11, 2013, 02:54:37 pm »
Still doesn't help with the error on why it crashes

TheDianamu

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Entry point must be defined
« Reply #12 on: October 11, 2013, 03:39:47 pm »
Anybody?

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Entry point must be defined
« Reply #13 on: October 11, 2013, 03:49:21 pm »
No need to bump your thread, learn to have patience.  ;)

One thing that sometimes causes these types of issues is when your mixing debug and release modes. And while your at it post a complete and minimal example that crashes.
« Last Edit: October 11, 2013, 03:52:13 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

TheDianamu

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Entry point must be defined
« Reply #14 on: October 12, 2013, 12:41:37 am »
I am getting

First-chance exception at 0x78aa1f34 in Game.exe: 0xC0000005: Access violation reading location 0x00133000.
Unhandled exception at 0x78aa1f34 in Game.exe: 0xC0000005: Access violation reading location 0x00133000.

With this code

#include "LEngine.h"
#include <SFML\Graphics.hpp>

void LEngine::Sprites(){
        sf::Texture t_grass;
        sf::Texture t_stone;
        sf::Texture t_water;

        t_grass.loadFromFile("grass.png");
        t_stone.loadFromFile("stone.png");
        t_water.loadFromFile("water.png");

        sf::Sprite grass;
        sf::Sprite stone;
        sf::Sprite water;

        grass.setTexture(t_grass);
        stone.setTexture(t_stone);
        water.setTexture(t_water);
}

void LEngine::Map(){
        int m_draw[50][50];

        for(int x = 0; x < 50; x++){
                for(int y = 0; y < 50; y++){
                        m_draw[x][y] = 50;
                }
        }

        sf::RectangleShape rect;
        rect.setSize(sf::Vector2f(16,16));

        for(int x = 0; x < 50; x++){
                for(int y = 0; y < 50; y++){
                        switch (m_draw[x][y]){
                        case 0:
                                rect.setFillColor(sf::Color::Green);
                                rect.setPosition(5 * 16, 5 * 16);
                                window->draw(rect);
                                break;
                        }
                }
        }
}

bool LEngine::Init(){
        window = new sf::RenderWindow(sf::VideoMode(800, 600, 32), "RPG");

        if(!window)
                return false;

        return true;
}

void LEngine::Events(){
        sf::Event evt;
        //Loop through all window events
        while(window->pollEvent(evt)){
                if(evt.type == sf::Event::Closed)
                        window->close();
        }
}

void LEngine::MainLoop(){
        while(window->isOpen()){
                Sprites();
                Map();
        }
}

void LEngine::boot(){
        if(!Init())
                throw "Could not initialize Engine";

        MainLoop();
}

 

anything