2

I'm using sfml 2.0. I know I can ask on there forum but I don't think it has anything to do with linking a library wrong because I compiled an example project fine and it's pretty much the exact same thin I'm just trying to incorporate an external class. I get this when I try to compile

1> LINK : fatal error LNK1104: cannot open file 'C:\Users\brr\documents\visual studio 2012\Projects\sfmlgame\Release\sfmlgame.exe'

My code is as follows:

main.cpp:

#include "functions.h"
int main()
{
    functions func;
    std::cout << "Testing 123, testing 123!";
    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>
#include <iostream>

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();
    }
}
borisbn
  • 4,988
  • 25
  • 42
user1068329
  • 31
  • 1
  • 1
  • 4
  • Does directory `C:\Users\brr\documents\visual studio 2012\Projects\sfmlgame\Release` exists and writeble ? Can you copy any file to it using explorer or other file-manager ? – borisbn Mar 19 '13 at 06:00
  • try do clean & build, is this error then reported too? – 4pie0 Mar 19 '13 at 06:11

3 Answers3

6

There are two possibilities.

1. You don't have access to the C:\Users\brr\documents\visual studio 2012\Projects\sfmlgame\Release directory. You can check by attempting to create a new file in this location.

2.The process is already in use. Run task manager(start->run->taskmgr), and check if sfmlgame.exe is running. If yes, kill the process.

jxh
  • 69,070
  • 8
  • 110
  • 193
  • Had this because was launching the program via ctrl+f5 in visual studio, for maximum performance. After I closed this program, it worked. Ctrl+f5 runs the code without attaching a debugger. The usual f5 attaches a debugger which is a lot slower (even in Release mode). – Kari Aug 14 '19 at 08:03
3
  1. go to task manager
  2. go to Processes tab
  3. look for the desired exe file
  4. click on End Processes
  5. build for project again
Ahmad Y. Saleh
  • 3,309
  • 7
  • 32
  • 43
2

One usually gets this error when they have the program (sfmlgame.exe) already open/running, so visual studio can't replace it with the newly compiled one. Close the program if you are already running it, then try again.

Jorge Israel Peña
  • 36,800
  • 16
  • 93
  • 123