简体   繁体   中英

Error C1083: Cannot open source file: "stdafx.cpp': No such file or directory

I have the above error and have followed all solutions but does not fix.

This is my stdafx.h file. I have it in the target directory, I can see the file and the full path goes to there. In addition, I have created a win32 project. Why is my code not working?

// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#include "targetver.h"

#include <stdio.h>
#include <tchar.h>



// TODO: reference additional headers your program requires here

ACTUAL CODE:

// ConsoleApplication1.cpp : Defines the entry point for the console application. //
#include "stdafx.h"
#include <iostream>

int main() {    std::cout << "Hello world!" << std::endl;   return 0; }

For the record, I had this problem when cloned a repo using git from the Ubuntu shell in Windows 10.

After I cloned the repo to a different location usin git from a Windows shell, the problem went away and the solution builds fine.

The issue was that the build scripts were looking for 'stdafx.cpp' in a folder with uppercase name ( C:\\GIT\\LIBRARYX\\SRC\\ ) and this path did not work if the solution was cloned using git from Ubuntu bash.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM