1

I'm currently working on making my own 2D game from scratch in C++ as a side project. The game is going to be using SFML for displaying textures and such, and because I can see myself making more than one game like this in the future, I thought it a good idea to separate out some of the components that I have built for future use as dynamic linked libraries.

Here lies the problem though: whenever I build my actual "game" project that requires one of the other projects that pull from the SFML library, I get errors telling me that "SFML/Window.hpp" doesn't exist.

2>------ Build started: Project: test-game, Configuration: Debug x64 ------
2>Test.cpp
2>c:\users\jsuskalo\documents\programming\projects\c++\2d-engine\render-engine\rewindow.h(4): fatal error C1083: Cannot open include file: 'SFML\Window.hpp': No such file or directory
2>Done building project "test-game.vcxproj" -- FAILED.

However if I simply compile the first project, which is the one that actually does a #include of the "SFML\Window.hpp" file, it compiles just fine.

Initially I assumed that perhaps I would just have to ensure the project could include and reference the libraries the same as the render project, but when I do that I got more errors:

1>------ Build started: Project: test-game, Configuration: Debug x64 ------
1>Test.cpp
1>c:\users\jsuskalo\documents\programming\projects\c++\2d-engine\test-game\test.cpp(7): error C2280: 'REWindow::REWindow(const REWindow &)': attempting to reference a deleted function
1>c:\users\jsuskalo\documents\programming\projects\c++\2d-engine\render-engine\rewindow.h(24): note: compiler has generated 'REWindow::REWindow' here
1>c:\users\jsuskalo\documents\programming\projects\c++\2d-engine\render-engine\rewindow.h(24): note: 'REWindow::REWindow(const REWindow &)': function was implicitly deleted because a data member invokes a deleted or inaccessible function 'sf::Window::Window(const sf::Window &)'
1>c:\users\jsuskalo\documents\programming\libraries\c++\sfml-2.4.2\include\sfml\window\window.hpp(530): note: 'sf::Window::Window(const sf::Window &)': function was implicitly deleted because a base class invokes a deleted or inaccessible function 'sf::NonCopyable::NonCopyable(const sf::NonCopyable &)'
1>Done building project "test-game.vcxproj" -- FAILED.

When I did the include and reference properties edits I closely followed the SFML tutorial on such (https://www.sfml-dev.org/tutorials/2.4/start-vc.php) so I have to wonder if it's something wrong with my code at this point.

Inside my render project I have the following header and code file: REWindow.h in the render-engine project:

#pragma once

#include <string>
#include <SFML\Window.hpp>

using namespace std;

class REWindow {
public:
    REWindow() : REWindow(800, 600, "Test Window", false) {};
    REWindow(int iX, int iY, string sName) : REWindow(iX, iY, sName, false) {};
    REWindow(int iX, int iY, string sName, bool bSplash);
    bool isOpen();
    bool updateEvents();
    bool shouldClose();
    void close();
    sf::Event event;

private:
    sf::Window window;
    int m_iX, m_iY;
    string m_sName;
    bool m_bSplash;
};

REWindow.cpp in the render-engine project:

#include "REWindow.h"

REWindow::REWindow(int iX, int iY, string sName, bool bSplash) : m_iX(iX),m_iY(iY), m_sName(sName), m_bSplash(bSplash) {
    if (bSplash) {
        sf::Window window(sf::VideoMode(iX, iY, sf::Style::None), sName);
    } else if (iX == -1 || iY == -1) {
        sf::VideoMode vmDM = sf::VideoMode::getDesktopMode();
        sf::Window window(sf::VideoMode(vmDM.width, vmDM.width, sf::Style::Fullscreen), sName);
    } else {
        sf::Window window(sf::VideoMode(m_iX, m_iY), sName);
    }
}

bool REWindow::isOpen() {
    return window.isOpen();
}

bool REWindow::updateEvents() {
    return window.pollEvent(event);
}

bool REWindow::shouldClose() {
    return event.type == sf::Event::Closed;
}

void REWindow::close() {
    window.close();
}

And finally the offending file (it seems), Test.cpp in the test-game project:

#include "REWindow.h"

using namespace std;

int main()
{
    REWindow wind = REWindow();
    while (wind.isOpen())
    {
        while (wind.updateEvents()) {
            if (wind.shouldClose()) {
                wind.close();
            }
        }
    }

    return 0;
}

So the final question is simply, is the problem likely in how I included the files, is it an inherent limitation in Visual Studio, and if so, how would I work around it, or is it simply a code error?

Suskeyhose
  • 33
  • 1
  • 4
  • While I haven't been able to solve this issue yet, it seems that it comes down to an issue with the fact that I am using a version of SFML for Visual C++ 2015 when I need it for Visual C++ 2017. I'm currently working towards building a version of SFML for Visual C++ 2017. – Suskeyhose Apr 28 '17 at 14:57
  • Check the 2 projects (the one that finds the file and the one that doesn't) for include paths related settings. My answer from [\[SO\]: How to include openssl in Visual Studio Expres 2012 Windows 7 x64](https://stackoverflow.com/questions/32156336/how-to-include-openssl-in-visual-studio-expres-2012-windows-7-x64) contains more details on the topic. – CristiFati Jun 07 '17 at 11:28

0 Answers0