Error LNK1104 cannot open file 'C:\Users\My\source\repos\C++_6\Debug\C++_6.exe'

Shervan360 1,661 Reputation points
2021-01-13T21:09:29.367+00:00

Hello,

How can I resolve this error?

Thanks

#include<iostream>  
using namespace std;  
  
int main()  
{  
	char str[] = "This is a sample string";  
  
	return 0;  
}  
  

56249-screenshot-2021-01-13-160631.jpg

Developer technologies C++
0 comments No comments
{count} vote

Accepted answer
  1. WayneAKing 4,931 Reputation points
    2021-01-19T04:43:09.673+00:00

    Jeanine already suggested that an antivirus or other
    security program may be blocking it. She also suggested
    that you set your directory as an exclusion in any AV/AM
    software you re running. Have you tried that?

    As further exploration along these lines, provide the
    following info:

    (1) What AV/AM/IS software are you using?

    (2) Have you tried executing your program with
    the security software temporarily disabled?

    Some security software can be very aggressive when
    analyzing unknown programs. As a result they sometimes
    trigger a false positive - identifying the program
    as possibly malicious when it isn't. When it does
    that it may block access to the file in question.

    I have seen this happen a number of times with very
    small sample programs that I was building. When the
    program was altered by adding or changing code, the
    false positive detection disappeared.

    When you change the string in your program you change
    the object code that is generated, and that may lead to
    a different assessment of the exe by the security software.

    In addition to testing with your security software
    briefly turned off, also experiment with the string
    that appears to be creating issues while adding
    some additional code to the source. Even if it
    isn't needed for the sample itself. For example:

    #include<iostream>
    using namespace std;
    
    int main()
    {
        int dummy[10] = {0};
    
        char str[] = "This is a sample string";
    
        return 0;
    }
    

    Or try this variation which uses a read-only
    string instead of the array in your example:

    #include<iostream>
    using namespace std;
    
    int main()
    {
        //char str[] = "This is a sample string";
        const char *str = "This is a sample string";
    
        return 0;
    }
    
    • Wayne
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Jeanine Zhang-MSFT 11,356 Reputation points Microsoft External Staff
    2021-01-14T01:57:06.313+00:00

    Hi,

    First of all, you could check if your application is already running. If so, you could try to stop the program and unload it from the debugger before building it again. If the app is open in another program, such as a resource editor, close it. If your program is unresponsive, you may need to use Task Manager to end the process. You might also need to close and restart Visual Studio.

    And some antivirus programs may temporarily block access to newly created files, especially .exe and .dll executable files. To fix this issue, try excluding your project build directories from the antivirus scanner.

    For more details I suggest you could refer to the Doc: Linker Tools Error LNK1104

    Best Regards,

    Jeanine

    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.