Can't compile code “launch: program does not exist ”

前端 未结 7 1502
醉话见心
醉话见心 2021-01-31 06:16

I have simple console application in C++ that I succeed to compile with Visual Studio.

I wanted to try Visual Studio Code so I copied the directory to the computer wit

相关标签:
7条回答
  • 2021-01-31 06:30

    Make sure your "program" and "cwd" properties are actually correct. Check the path it tells you and compare with the path you want them to be.

    0 讨论(0)
  • 2021-01-31 06:35

    Spent 2 hours on this.

    Ideally, VS Code shouldn't make so difficult for beginners

    VS Code can give prompts for each installation, etc. automatically, in a step by step manner, like Idea editors, so that it wont be so long procedure for beginners.

    Sequence of steps to do (most of the things are one time):

      
        one time:  
            install a C/C++ complier, add to PATH environment variable  
            install C/C++ plugin for visual studio code  
            tell visual studio code where the compiler is and what is the short cut to build and run  
               these are files under ".vscode" (see below)
        every project:  
            crate a project  
            build project  
            run project  
    

    Detailed:

    One time:

    
    Note: Point 'A' below can be skipped if you already have a compiler.
    
    A. Install a compiler (if you don't have one already)  
        Example below, installs MinGW c++ compiler on Windows:  
        Download from here: https://sourceforge.net/p/mingw-w64/mailman/message/36103143/  
        1. For windows, I downloaded https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-v5.0.3.zip  
        2. unzip mingw-w64-v5.0.3.zip  
        3. rename unzipped folder to MinGW, Move it to C:\MinGW\  
        4. verify that you have "C:\MinGW\bin\gcc.exe" director/file, otherwise make necessary change to folder  
    
    B. Add your compiler to PATH environment variable
        1. Add "C:\MinGW\bin" to PATH > user environment variable  
        2. verify gcc command works from cmd  
            restart your cmd  
            run below command in 'cmd'  
                where gcc  
                The output should be: C:\MinGW\bin\gcc.exe  
    
    C. Restart your visual studio code  
        1. install C/C++ plugin, as below:  
            From Menu  
                 View > Extension  
            Search & Install below extension  
                C/C++  
    
    

    Every project:

    Note: You can copy paste the .vscode folder every time

    
    A. Create a below "myproj" folder & files, like below in below structure:  
        C:\myproj\myfile.cpp  
        C:\myproj\.vscode\  
        C:\myproj\.vscode\c_cpp_properties.json  
        C:\myproj\.vscode\launch.json  
        C:\myproj\.vscode\settings.json  
        C:\myproj\.vscode\tasks.json  
    
    

    B. Download & overwrite the above ((5 files)), from below link

    https://github.com/manoharreddyporeddy/my-programming-language-notes/tree/master/vscode-c%2B%2B

    C. Restart your visual studio/vs code  
    
    D. Open project in vs code & run project:
    
      Drag and drop "myproj" folder into visual studio code  
      BUILD PROJECT:   press "Ctrl + Shift + B" to build your myfile.exe  
      RUN PROJECT:     press "Ctrl + F5" to run your myfile.exe  
    
    

    Thats all, hope that helped.

    More info: https://code.visualstudio.com/docs/languages/cpp

    Optional

    To format C++ better

    
    C++ formatting
      1. Install Clang:
         Download from: http://releases.llvm.org/download.html#5.0.2
          I have downloaded for windows 
            "Pre-Built Binaries:" > Clang for Windows (64-bit) (LLVM-6.0.0-win64.exe)  
      2. Select Add to PATH while installing.  
      3. Install vs code plugin "Clang-Format" by xaver, this wraps above exe.  
      4. Restart visual studio code.  
      Note:
       Issue:    As of June 2018, Clang does not format the newer C++17 syntax correctly.
       Solution: If so, move that code to another file/ comment & restart the vs code.
    
      That's all. Now press Alt+Shift+F to format (similar key combination in other OS)
    
    
    0 讨论(0)
  • 2021-01-31 06:43

    The error ".exe file does not exist" in vscode can occur because of the following reasons: 1. If the program contains white spaces 2. If there is re-declaration of variables or other kind of compilation errors

    0 讨论(0)
  • 2021-01-31 06:43

    This problem is mainly due file name , as per below table the name of the binary will be audioMatrixBin in windows folder not audioMatrixBin.exe, but we have to mention filename.exe here.

        {
            "name": "(Windows) Launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "audioMatrixBin.exe",
            "args": ["AudioMxrMgr4Subaru.conf"],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true
        }
    ]
    

    }

    0 讨论(0)
  • 2021-01-31 06:45

    the problem for me was an error during the run time that the compiler didn't notice before. then the .exe file didn't built, therefore the .exe file does not exist so you have to check if your script is fine even if no error is found by the debugger.

    0 讨论(0)
  • 2021-01-31 06:50

    BUILD your PROJECT .exe file : press "Ctrl + Shift + B" to build your example.exe

    0 讨论(0)
提交回复
热议问题