发行C ++项目。 “找不到'FILEPATH \ Debug \main.obj'。FILENAME是使用/ DEBUG:FASTLINK

时间:2018-11-26 10:07:12

标签: c++ visual-studio compiler-errors visual-studio-2017 sfml

我正在使用SFML库在VS2017中以C ++构建ASCII转换器。我相信我的基本逻辑是正确的,事物的语法应该不会有任何错误,但是我对VS并使用外部包含进行编译有些陌生。

当我尝试构建用于调试的程序时,VS抛出此错误:

  

找不到“ FILEPATH \ Debug \ main.obj”。 FILENAME与   / DEBUG:FASTLINK,该文件需要用于调试的对象文件。

     

后续失败将记录到“输出”的“调试”窗格中   窗口。

我相信我正确设置了SFML,以供参考,我在this tutorial之后跟随了“ Hilze Vonck”。

大多数常见解决方案都指向确保链接器输出文件为$(OutDir)$(TargetName)$(TargetExt)。我的就是这样。我发现的所有解决方案均未产生任何结果。

经过一些修改,我的项目文件夹保存在以下位置:

  

E:\ Google云端硬盘\学院\ XXXXXX XXXX X \ CGT   XXX \ CGTXXX_XXXXXXX_XXXXX_Final_Project \ ASCII_Converter

不确定是否会有所作为,但是您就可以了。


就我要构建的文件而言,再次不确定是否有助于解决该问题,但这是:

//CGT *** Final Project: Image to ASCII Converter
//J**** W******
//Pass 01


//Researching into how this would be done led me to believe that including some sort
//of external framework might be the way to go. SFML seemed to be a popular one and
//I'd used it once for a project back at Butler. Might not need it, but research leads
//me to believe it'll be useful.
#include <SFML/Graphics.hpp>

//Future me, here's a link to the Image Classes:
//https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Image.php

#include <string>
#include <iostream>
//Going to need to read in files. Hence the <fstream>
#include <fstream>
#include <time.h>

using namespace std;
//For SFML
using namespace sf;



//This will assign the appropriate ASCII character for the grayscale intensity/RGB of
//each pixel. Works as of now. Bless.
char assignAsciiChar(int grayscaleValue, string grayscaleRange) {
    //God bless the TA's. (int) is a thing I can do. Horray.
    return grayscaleRange[(int)(grayscaleValue/255.f*grayscaleRange.size())];
}


//I think I'll only need one function, seeing as I don't want to make a super mega loop
int main()
{
    //[pixelSize]: Will allow for variable resolutions by sampling the grayscale value of
    //a user-defined number of pixels. 1x1, 2x2, 4x4, 8x8. You get the deal, future me.


    //[avalibleCharacters]: I'll make a string full of characters that can be used within
    //this ASCII piece going from super white to super dark. That way I don't have to
    //account for allpotential characters.

    //[inputLocation & outputLocation]: Strings defining the filepath of the image to
    //be converted and the .txt file to be output

    //[ASCII]: Output string for the ASCII art file.

    //[picture & grayscalePicture]: SFML Image types that represent the imported image
    //and the image converted to grayscale respectively.

    //[grayscaleDownscaledPicture]: Represents the grayscaled image downsized by
    //user-specified pixel size. This is the imagedata that will be converted to ASCII.

    //[grayscaleRange]: A string that contains the standard greyscale ramp.
    //Referenced http://paulbourke.net/dataformats/asciiart/
    int pixelSizeX = 1;
    int pixelSizeY = 2;
    int gsValue = 0;
    string inputLocation;
    string outputLocation;
    //Presently just a static ramp of values. Maybe I'll expand to allow user input?
    string grayscaleRange = "$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,^`'. ";
    string ASCII;
    Image picture;
    Image grayscalePicture(picture);
    Image grayscaleDownscaledPicture(picture);

    cout << "Give input filepath for the image you'd like to convert:  ";
    cin >> inputLocation;
    cout << "Give output filepath where you'd like file to be saved:  ";
    cin >> outputLocation;
    cout << "ASCII character represents \"x by x\" pixels (give \"x\"):  ";
    cin >> pixelSizeX;

    //I think this is correct syntax to load with SFML.
    picture.loadFromFile(inputLocation);

    double rCon = .213;
    double gCon = .715;
    double bCon = .072;

    //Conversion from color image to black and white image
    //OH LORD I THINK THIS WORKS
    for (int h = 0; h < picture.getSize().x; h++) {
        for (int i = 0; i < picture.getSize().y; i++) {
            //ACTUAL CONVERSION TO GO HERE
            //WILL LIKELY USE getPixel()
            //Apparently need double colon? Don't know why we need to scope it, but that's what works. Thanks TAs.
            grayscalePicture.setPixel(h, i, Color::Color(picture.getPixel(h, i).r*rCon + picture.getPixel(h, i).g*gCon + picture.getPixel(h, i).b*bCon, picture.getPixel(h, i).r*rCon + picture.getPixel(h, i).g*gCon + picture.getPixel(h, i).b*bCon, picture.getPixel(h, i).r*rCon + picture.getPixel(h, i).g*gCon + picture.getPixel(h, i).b*bCon));
        }
    }

    //Sizing down image as per the user specified pixelSize
    //Holy crap this is sloppy. Well, it *works*. Maybe shoot for not having so many nested for loops.
    pixelSizeY = 2 * pixelSizeX;
    for (int j = 0; j < picture.getSize().x; j += pixelSizeX) {
        for (int k = 0; k < picture.getSize().y; k += pixelSizeY) {
            for (int l = 0; l < pixelSizeX; l++) {
                for (int m = 0; m < pixelSizeY; m++) {
                    gsValue += grayscalePicture.getPixel(j*l, k*m).r;
                }
            }
            //Ask if /= is good syntax
            gsValue /= pixelSizeX + pixelSizeX + 1;
            for (int n = 0; n < pixelSizeX; n++) {
                for (int o = 0; o < pixelSizeY; o++) {
                    grayscaleDownscaledPicture.setPixel(j + n, k + o, Color::Color(gsValue, gsValue, gsValue));
                }
            }
        }
    }

    //Conversion from bwPicture to ASCII
    int tempASCII = 0;
    for (int p = 0; p < grayscaleDownscaledPicture.getSize().y; p += pixelSizeY) {
        for (int q = 0; q < grayscaleDownscaledPicture.getSize().x; q += pixelSizeX) {
            ASCII += assignAsciiChar(grayscaleDownscaledPicture.getPixel(p, q).r, grayscaleRange);
        }
        //Alternate way to make a new line. Neat. Remember this, future me.
        ASCII += "\n";
        tempASCII++;
    }
    //Output to .txt file
    ofstream output(outputLocation);
    cout << "ASCCI art saved in this filepath:  " << outputLocation;
    cout << endl;
    cout << "Press a key to close application.";
    cin.get;
    cin.get;
    return 0;
}

鉴于抛出的特定错误,我想假设问题出在VS环境中。但是我的代码也恰好是一大堆垃圾。

0 个答案:

没有答案