./a.out results '.' is not recognized as an internal or external command, operable program or batch file












0















I am very new to c++ and using the command prompt.



I have multiple .cpp and .h files that run fine on my IDE (Code::blocks) running GNU GCC as the compiler. It displays what I need it too but when I try to use the command prompt and type "g++ file1.cpp file2.cpp ...." then "./a.out


I get the error "'.' is not recognized as an internal or external command, operable program or batch file."
I have cygwin64 with the proper g++, cdb, make packages installed and the path setup.



what have I messed up?










share|improve this question























  • the output file most likely is not executable, try sudo chmod +x a.out

    – Chris Mc
    Nov 20 '18 at 5:44











  • @ChrisMc this question is about windows and command prompt. sudo is for linux

    – Mohammadreza Panahi
    Nov 20 '18 at 5:47











  • Could you add on the full chain of events? Delete all of the generated files and then run your build command line. Copy everything (well almost everything. The command all of the output, but not your banking records. Best if we don't see that) and paste it into the question. One of the eagle-eyed folk out here might spot something you've missed.

    – user4581301
    Nov 20 '18 at 6:10






  • 1





    It looks like you're applying Linux command line instructions to a Windows command prompt.

    – chris
    Nov 20 '18 at 6:14






  • 1





    g++ on windows outputs executable a.exe. Yet another case: you got compiler errors and you hid this important information from the community.

    – S.M.
    Nov 20 '18 at 6:38
















0















I am very new to c++ and using the command prompt.



I have multiple .cpp and .h files that run fine on my IDE (Code::blocks) running GNU GCC as the compiler. It displays what I need it too but when I try to use the command prompt and type "g++ file1.cpp file2.cpp ...." then "./a.out


I get the error "'.' is not recognized as an internal or external command, operable program or batch file."
I have cygwin64 with the proper g++, cdb, make packages installed and the path setup.



what have I messed up?










share|improve this question























  • the output file most likely is not executable, try sudo chmod +x a.out

    – Chris Mc
    Nov 20 '18 at 5:44











  • @ChrisMc this question is about windows and command prompt. sudo is for linux

    – Mohammadreza Panahi
    Nov 20 '18 at 5:47











  • Could you add on the full chain of events? Delete all of the generated files and then run your build command line. Copy everything (well almost everything. The command all of the output, but not your banking records. Best if we don't see that) and paste it into the question. One of the eagle-eyed folk out here might spot something you've missed.

    – user4581301
    Nov 20 '18 at 6:10






  • 1





    It looks like you're applying Linux command line instructions to a Windows command prompt.

    – chris
    Nov 20 '18 at 6:14






  • 1





    g++ on windows outputs executable a.exe. Yet another case: you got compiler errors and you hid this important information from the community.

    – S.M.
    Nov 20 '18 at 6:38














0












0








0








I am very new to c++ and using the command prompt.



I have multiple .cpp and .h files that run fine on my IDE (Code::blocks) running GNU GCC as the compiler. It displays what I need it too but when I try to use the command prompt and type "g++ file1.cpp file2.cpp ...." then "./a.out


I get the error "'.' is not recognized as an internal or external command, operable program or batch file."
I have cygwin64 with the proper g++, cdb, make packages installed and the path setup.



what have I messed up?










share|improve this question














I am very new to c++ and using the command prompt.



I have multiple .cpp and .h files that run fine on my IDE (Code::blocks) running GNU GCC as the compiler. It displays what I need it too but when I try to use the command prompt and type "g++ file1.cpp file2.cpp ...." then "./a.out


I get the error "'.' is not recognized as an internal or external command, operable program or batch file."
I have cygwin64 with the proper g++, cdb, make packages installed and the path setup.



what have I messed up?







c++ command command-prompt






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 5:32









Matt RojasMatt Rojas

81




81













  • the output file most likely is not executable, try sudo chmod +x a.out

    – Chris Mc
    Nov 20 '18 at 5:44











  • @ChrisMc this question is about windows and command prompt. sudo is for linux

    – Mohammadreza Panahi
    Nov 20 '18 at 5:47











  • Could you add on the full chain of events? Delete all of the generated files and then run your build command line. Copy everything (well almost everything. The command all of the output, but not your banking records. Best if we don't see that) and paste it into the question. One of the eagle-eyed folk out here might spot something you've missed.

    – user4581301
    Nov 20 '18 at 6:10






  • 1





    It looks like you're applying Linux command line instructions to a Windows command prompt.

    – chris
    Nov 20 '18 at 6:14






  • 1





    g++ on windows outputs executable a.exe. Yet another case: you got compiler errors and you hid this important information from the community.

    – S.M.
    Nov 20 '18 at 6:38



















  • the output file most likely is not executable, try sudo chmod +x a.out

    – Chris Mc
    Nov 20 '18 at 5:44











  • @ChrisMc this question is about windows and command prompt. sudo is for linux

    – Mohammadreza Panahi
    Nov 20 '18 at 5:47











  • Could you add on the full chain of events? Delete all of the generated files and then run your build command line. Copy everything (well almost everything. The command all of the output, but not your banking records. Best if we don't see that) and paste it into the question. One of the eagle-eyed folk out here might spot something you've missed.

    – user4581301
    Nov 20 '18 at 6:10






  • 1





    It looks like you're applying Linux command line instructions to a Windows command prompt.

    – chris
    Nov 20 '18 at 6:14






  • 1





    g++ on windows outputs executable a.exe. Yet another case: you got compiler errors and you hid this important information from the community.

    – S.M.
    Nov 20 '18 at 6:38

















the output file most likely is not executable, try sudo chmod +x a.out

– Chris Mc
Nov 20 '18 at 5:44





the output file most likely is not executable, try sudo chmod +x a.out

– Chris Mc
Nov 20 '18 at 5:44













@ChrisMc this question is about windows and command prompt. sudo is for linux

– Mohammadreza Panahi
Nov 20 '18 at 5:47





@ChrisMc this question is about windows and command prompt. sudo is for linux

– Mohammadreza Panahi
Nov 20 '18 at 5:47













Could you add on the full chain of events? Delete all of the generated files and then run your build command line. Copy everything (well almost everything. The command all of the output, but not your banking records. Best if we don't see that) and paste it into the question. One of the eagle-eyed folk out here might spot something you've missed.

– user4581301
Nov 20 '18 at 6:10





Could you add on the full chain of events? Delete all of the generated files and then run your build command line. Copy everything (well almost everything. The command all of the output, but not your banking records. Best if we don't see that) and paste it into the question. One of the eagle-eyed folk out here might spot something you've missed.

– user4581301
Nov 20 '18 at 6:10




1




1





It looks like you're applying Linux command line instructions to a Windows command prompt.

– chris
Nov 20 '18 at 6:14





It looks like you're applying Linux command line instructions to a Windows command prompt.

– chris
Nov 20 '18 at 6:14




1




1





g++ on windows outputs executable a.exe. Yet another case: you got compiler errors and you hid this important information from the community.

– S.M.
Nov 20 '18 at 6:38





g++ on windows outputs executable a.exe. Yet another case: you got compiler errors and you hid this important information from the community.

– S.M.
Nov 20 '18 at 6:38












2 Answers
2






active

oldest

votes


















2














In command-prompt you just add executable filename (e.g. out.exe)



In powershell run the executable file like .out.exe.



The command :



g++ -c [source file].cpp produces object file [source file].o


And The command :



g++ -o [executable file] [object file].o produces object file [executable]


For example Compiling "hello.cpp" into executable "hello.exe" in one step and running it :




Z:cpp> g++ -o hello.exe hello.cpp
Z:cpp> hello.exe



Create the exe file using object files :




Z:cpp> g++ -c file1.cpp
Z:cpp> g++ -c file2.cpp
Z:cpp> g++ -o out.exe file1.o file1.o
Z:cpp> out.exe






share|improve this answer

































    2














    I am guessing you are following a recipe or tutorial that was designed for Unix-like systems such as Linux, but you are using Windows.



    In Linux, the character . means the current directory, while a forward slash / is the directory separator. So, this:



    ./a.out


    refers to the file named a.out in the current directory.



    In Windows, . still refers to the current directory, but instead of a forward slash, a backward slash is used to separate directories. So, this:



    .a.out


    refers to the file named a.out in the current directory.



    However that is still not the answer: on Linux, if you do not specify otherwise, the g++ command will produce an executable called a.out (strange name, but it is named that for historical reasons). Under windows, however, that is not a valid name for an executable, as Windows requires executables to end in .exe. As a result, if you don't specify other wise, the executable will be named:



    a.exe


    Yet another difference: in Windows, the path includes the current directory by default, so you do not even need to specify the . on the front.






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386805%2fa-out-results-is-not-recognized-as-an-internal-or-external-command-operab%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      In command-prompt you just add executable filename (e.g. out.exe)



      In powershell run the executable file like .out.exe.



      The command :



      g++ -c [source file].cpp produces object file [source file].o


      And The command :



      g++ -o [executable file] [object file].o produces object file [executable]


      For example Compiling "hello.cpp" into executable "hello.exe" in one step and running it :




      Z:cpp> g++ -o hello.exe hello.cpp
      Z:cpp> hello.exe



      Create the exe file using object files :




      Z:cpp> g++ -c file1.cpp
      Z:cpp> g++ -c file2.cpp
      Z:cpp> g++ -o out.exe file1.o file1.o
      Z:cpp> out.exe






      share|improve this answer






























        2














        In command-prompt you just add executable filename (e.g. out.exe)



        In powershell run the executable file like .out.exe.



        The command :



        g++ -c [source file].cpp produces object file [source file].o


        And The command :



        g++ -o [executable file] [object file].o produces object file [executable]


        For example Compiling "hello.cpp" into executable "hello.exe" in one step and running it :




        Z:cpp> g++ -o hello.exe hello.cpp
        Z:cpp> hello.exe



        Create the exe file using object files :




        Z:cpp> g++ -c file1.cpp
        Z:cpp> g++ -c file2.cpp
        Z:cpp> g++ -o out.exe file1.o file1.o
        Z:cpp> out.exe






        share|improve this answer




























          2












          2








          2







          In command-prompt you just add executable filename (e.g. out.exe)



          In powershell run the executable file like .out.exe.



          The command :



          g++ -c [source file].cpp produces object file [source file].o


          And The command :



          g++ -o [executable file] [object file].o produces object file [executable]


          For example Compiling "hello.cpp" into executable "hello.exe" in one step and running it :




          Z:cpp> g++ -o hello.exe hello.cpp
          Z:cpp> hello.exe



          Create the exe file using object files :




          Z:cpp> g++ -c file1.cpp
          Z:cpp> g++ -c file2.cpp
          Z:cpp> g++ -o out.exe file1.o file1.o
          Z:cpp> out.exe






          share|improve this answer















          In command-prompt you just add executable filename (e.g. out.exe)



          In powershell run the executable file like .out.exe.



          The command :



          g++ -c [source file].cpp produces object file [source file].o


          And The command :



          g++ -o [executable file] [object file].o produces object file [executable]


          For example Compiling "hello.cpp" into executable "hello.exe" in one step and running it :




          Z:cpp> g++ -o hello.exe hello.cpp
          Z:cpp> hello.exe



          Create the exe file using object files :




          Z:cpp> g++ -c file1.cpp
          Z:cpp> g++ -c file2.cpp
          Z:cpp> g++ -o out.exe file1.o file1.o
          Z:cpp> out.exe







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 20 '18 at 10:07

























          answered Nov 20 '18 at 5:54









          Mohammadreza PanahiMohammadreza Panahi

          2,60221432




          2,60221432

























              2














              I am guessing you are following a recipe or tutorial that was designed for Unix-like systems such as Linux, but you are using Windows.



              In Linux, the character . means the current directory, while a forward slash / is the directory separator. So, this:



              ./a.out


              refers to the file named a.out in the current directory.



              In Windows, . still refers to the current directory, but instead of a forward slash, a backward slash is used to separate directories. So, this:



              .a.out


              refers to the file named a.out in the current directory.



              However that is still not the answer: on Linux, if you do not specify otherwise, the g++ command will produce an executable called a.out (strange name, but it is named that for historical reasons). Under windows, however, that is not a valid name for an executable, as Windows requires executables to end in .exe. As a result, if you don't specify other wise, the executable will be named:



              a.exe


              Yet another difference: in Windows, the path includes the current directory by default, so you do not even need to specify the . on the front.






              share|improve this answer




























                2














                I am guessing you are following a recipe or tutorial that was designed for Unix-like systems such as Linux, but you are using Windows.



                In Linux, the character . means the current directory, while a forward slash / is the directory separator. So, this:



                ./a.out


                refers to the file named a.out in the current directory.



                In Windows, . still refers to the current directory, but instead of a forward slash, a backward slash is used to separate directories. So, this:



                .a.out


                refers to the file named a.out in the current directory.



                However that is still not the answer: on Linux, if you do not specify otherwise, the g++ command will produce an executable called a.out (strange name, but it is named that for historical reasons). Under windows, however, that is not a valid name for an executable, as Windows requires executables to end in .exe. As a result, if you don't specify other wise, the executable will be named:



                a.exe


                Yet another difference: in Windows, the path includes the current directory by default, so you do not even need to specify the . on the front.






                share|improve this answer


























                  2












                  2








                  2







                  I am guessing you are following a recipe or tutorial that was designed for Unix-like systems such as Linux, but you are using Windows.



                  In Linux, the character . means the current directory, while a forward slash / is the directory separator. So, this:



                  ./a.out


                  refers to the file named a.out in the current directory.



                  In Windows, . still refers to the current directory, but instead of a forward slash, a backward slash is used to separate directories. So, this:



                  .a.out


                  refers to the file named a.out in the current directory.



                  However that is still not the answer: on Linux, if you do not specify otherwise, the g++ command will produce an executable called a.out (strange name, but it is named that for historical reasons). Under windows, however, that is not a valid name for an executable, as Windows requires executables to end in .exe. As a result, if you don't specify other wise, the executable will be named:



                  a.exe


                  Yet another difference: in Windows, the path includes the current directory by default, so you do not even need to specify the . on the front.






                  share|improve this answer













                  I am guessing you are following a recipe or tutorial that was designed for Unix-like systems such as Linux, but you are using Windows.



                  In Linux, the character . means the current directory, while a forward slash / is the directory separator. So, this:



                  ./a.out


                  refers to the file named a.out in the current directory.



                  In Windows, . still refers to the current directory, but instead of a forward slash, a backward slash is used to separate directories. So, this:



                  .a.out


                  refers to the file named a.out in the current directory.



                  However that is still not the answer: on Linux, if you do not specify otherwise, the g++ command will produce an executable called a.out (strange name, but it is named that for historical reasons). Under windows, however, that is not a valid name for an executable, as Windows requires executables to end in .exe. As a result, if you don't specify other wise, the executable will be named:



                  a.exe


                  Yet another difference: in Windows, the path includes the current directory by default, so you do not even need to specify the . on the front.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 20 '18 at 6:37









                  harmicharmic

                  15.8k23458




                  15.8k23458






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386805%2fa-out-results-is-not-recognized-as-an-internal-or-external-command-operab%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

                      ComboBox Display Member on multiple fields

                      Is it possible to collect Nectar points via Trainline?