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

Author Topic: Link error .exe  (Read 3219 times)

0 Members and 2 Guests are viewing this topic.

Christopher Jozwiak

  • Newbie
  • *
  • Posts: 48
    • View Profile
    • Blog
    • Email
Link error .exe
« 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();
        }
       
}
Noob C++ Programmer.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Link error .exe
« Reply #1 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.
Laurent Gomila - SFML developer

Christopher Jozwiak

  • Newbie
  • *
  • Posts: 48
    • View Profile
    • Blog
    • Email
Re: Link error .exe
« Reply #2 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.
Noob C++ Programmer.

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: Link error .exe
« Reply #3 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

Christopher Jozwiak

  • Newbie
  • *
  • Posts: 48
    • View Profile
    • Blog
    • Email
Re: Link error .exe
« Reply #4 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?
Noob C++ Programmer.

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: Link error .exe
« Reply #5 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

Christopher Jozwiak

  • Newbie
  • *
  • Posts: 48
    • View Profile
    • Blog
    • Email
Re: Link error .exe
« Reply #6 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!
Noob C++ Programmer.

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: Link error .exe
« Reply #7 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  ;)

Christopher Jozwiak

  • Newbie
  • *
  • Posts: 48
    • View Profile
    • Blog
    • Email
Re: Link error .exe
« Reply #8 on: March 19, 2013, 07:23:57 pm »
Thanks for the motivation, don't get that too much :P
Noob C++ Programmer.