SFML community forums

Help => General => Topic started by: Christopher Jozwiak on March 19, 2013, 06:08:30 am

Title: Link error .exe
Post by: Christopher Jozwiak on March 19, 2013, 06:08:30 am
Hello I'm trying to figure out how to use classes with sfml.  I know I can but this is the first i've programmed oo style. I'm fairly new to programming in C++ altogether.  I'm using vs 2012 and I'm getting the error:
1>LINK : fatal error LNK1104: cannot open file 'C:\Users\brr\documents\visual studio 2012\Projects\sfmlgame\Release\sfmlgame.exe'

Here's my main.cpp:

#include "functions.h"
int main()
{
        functions func;
       
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);
        bool running = true;
    while (running)
    {
 
                func.window.clear();
        func.window.draw(shape);
        func.window.display();
    }

    return 0;
}

functions.h:

#pragma once
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include<SFML\Network.hpp>
#include <SFML/Window.hpp>
class functions
{
public:
        functions(void);
        ~functions(void);
        void Events();
        void Window();
        sf::RenderWindow window;
        sf::Event event;
       
};

 

functions.cpp:


#include "functions.h"




functions::functions(void)
{
}


functions::~functions(void)
{
}

void functions::Window(){
        window.setSize(sf::Vector2u(800,600));
        window.setTitle("Test");
       


}

void functions::Events(){
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
       
}
Title: Re: Link error .exe
Post by: Laurent on March 19, 2013, 06:34:31 am
Make sure that your executable is not running when you compile it. Since there's no way to end it in your code, it might be running forever in background.
Title: Re: Link error .exe
Post by: Christopher Jozwiak on March 19, 2013, 06:27:13 pm
Ya it worked not the only problem is its not doing what I want it to do the window wont open. it just displays a console window.
Title: Re: Link error .exe
Post by: AlexAUT on March 19, 2013, 06:33:17 pm
Maybe you should have a look again at the tutorial for SFML Windows http://www.sfml-dev.org/tutorials/2.0/window-window.php


You have to create the window: window.create(...), before you can use it.


AlexAUT
Title: Re: Link error .exe
Post by: Christopher Jozwiak on March 19, 2013, 06:50:54 pm
Okay got that working. Would I have to have my event function as a thread to have it run along with the window?
Title: Re: Link error .exe
Post by: AlexAUT on March 19, 2013, 06:54:10 pm
No its not necessary.

Normal gameloop: check for Events -> DoLogic -> Clear the window -> Draw some stuff -> Display


while(window.isOpen() && running)
{
    //Check events
    //DoLogic
    //Rendering
}

 


AlexAUT
Title: Re: Link error .exe
Post by: Christopher Jozwiak on March 19, 2013, 06:58:23 pm
Doh! I was putting my function call out of while (running)...  It's working now.  I think I can get it from here.  Took forever for me to even comprehend classes!
Title: Re: Link error .exe
Post by: AlexAUT on March 19, 2013, 07:18:26 pm
Everyone has to begin with small steps. Keep on working and stay focused and everything will turn right  ;)
Title: Re: Link error .exe
Post by: Christopher Jozwiak on March 19, 2013, 07:23:57 pm
Thanks for the motivation, don't get that too much :P