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

Author Topic: Problem with Building Project: "cannot open file 'sfml-window-d.lib"  (Read 2456 times)

0 Members and 1 Guest are viewing this topic.

CyanYoh

  • Newbie
  • *
  • Posts: 2
    • View Profile
When trying to run my C++ project in VS2017, I'm finding myself unable to build out my project. The specific error I'm getting is Code: LNK1104 Description: cannot open file 'sfml-window-d.lib'.

When setting up SFML, I referenced the startup file on your site and this tutorial (). I believe my code is alright, and I'll include it below, so I imagine I'm messing up with how I set up my linker.

Here's an Imgur album with screenshots of my folder setup and Properties window with the linker and whatnot: (https://imgur.com/a/pmDrZm3). I can add more screenshots if there's something you'd like to see that's missing.

As for the code, I don't think it's the issue here, but here it is:

#include <SFML/Graphics.hpp>
#include <string>
#include <iostream>
#include <fstream>

using namespace std;
using namespace sf;

double RED_COEFF = 0.2125;
double GREEN_COEFF = 0.7154;
double BLUE_COEFF = 0.0721;

char getCorrespondingAsciiChar(int grayScale, string among) {
        return among[(int)(grayScale / 255.f*among.size())];
}

int main() {
        int Xresolution;
        string path;
        string outputPath;
        string customChar;
        string among = "@%#Oo*+=-:. ";
        cout << "JPG to ASCII Converter" << endl << "by XXXXX XXXXXXX for XXXXXX" << endl;
        cout << endl << "Input the path of the image you want ot convert:  ";
        cin >> path;
        cout << endl << "Input the output path for the ASCII art: ";
        cin >> outputPath;
        cout << endl << "How many pixels will one ASCII character represent?  ";
        cin >> Xresolution;
        Image image;
        image.loadFromFile(path);

        Image bwImage(image);


        //Conversion from Regular to Grayscale
        for (int i = 0; i < image.getSize().x; i++) {
                for (int j = 0; j < image.getSize().y; j++) {
                        bwImage.setPixel(i, j, Color::Color(image.getPixel(i, j).r*RED_COEFF + image.getPixel(i, j).g*GREEN_COEFF + image.getPixel(i, j).b*BLUE_COEFF, image.getPixel(i, j).r*RED_COEFF + image.getPixel(i, j).g*GREEN_COEFF + image.getPixel(i, j).b*BLUE_COEFF, image.getPixel(i, j).r*RED_COEFF + image.getPixel(i, j).g*GREEN_COEFF + image.getPixel(i, j).b*BLUE_COEFF));
                }
        }

        //Conversion from Grayscale to Down Resolution
        int Yresolution = 2 * Xresolution;
        Image bwLowResImage(image);
        int grey = 0;
        for (int i = 0; i < image.getSize().x; i += Xresolution) {
                for (int j = 0; j < image.getSize().y; j += Yresolution) {
                        for (int x = 0; x < Xresolution; x++) {
                                for (int y = 0; y < Yresolution; y++) {
                                        grey += bwImage.getPixel(i + x, j + y).r;
                                }
                        }
                        grey /= Xresolution * Yresolution + 1;
                        for (int x = 0; x < Xresolution; x++) {
                                for (int y = 0; y < Yresolution; y++) {
                                        bwLowResImage.setPixel(i + x, j + y, Color::Color(grey, grey, grey));
                                }
                        }
                }
        }

        //Conversion from Down Resolution to ASCII
        string asciiArt;
        int lol = 0;
        for (int j = 0; j < bwLowResImage.getSize().y; j += Yresolution) {
                for (int i = 0; i < bwLowResImage.getSize().x; i += Xresolution) {
                        asciiArt += getCorrespondingAsciiChar(bwLowResImage.getPixel(i, j).r, among);
                }
                asciiArt += "\n";
                lol++;
        }
        ofstream output(outputPath);
        cout << "Conversion complete. ASCII art file can befound as: " << outputPath;
        cin.get();
        cin.get();
        return 0;
}

Thanks for any help you might be able to provide. I'm pulling my hair out here.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Problem with Building Project: "cannot open file 'sfml-window-d.lib"
« Reply #1 on: November 27, 2018, 06:09:00 pm »
Your linker setup looks ok. Are you sure that you have the SFML version built for VS2017?
Laurent Gomila - SFML developer

CyanYoh

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Problem with Building Project: "cannot open file 'sfml-window-d.lib"
« Reply #2 on: November 27, 2018, 06:32:36 pm »
I'm using SFML 2.5.1, which I believe is the correct version for VS 2017.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Problem with Building Project: "cannot open file 'sfml-window-d.lib"
« Reply #3 on: November 28, 2018, 06:38:03 am »
I mean, did you download the archive of SFML 2.5.1 which was built with VS2017? Look at the download page, there are packages for various compilers and OSes.
Laurent Gomila - SFML developer