Ubuntu 18.04 think C/C++ source code file is plain text

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












When I try to create a C/C++ source file



touch test.cpp


Usually it will generate a file which type is C source code file. But today I got a plain text file.
enter image description here



And I write a simple program in it like:



#include <stdio.h>
int main()
printf("hello");


Then I use G++ to compile it:



g++ test.cpp -o test


However, I got a sharedlib file instead of executable file.
enter image description here



And I can run the sharedlib file and get the correct ouput:



./test
hello


In the past, I can directly create a C++ source code file and this file type is easy to edit in vscode. But the plain text file is not comfortable for me.



So the two questions really bother me:



  1. why my Ubuntu can not recognize C/C++ source code file correctly?

  2. why I get a sharedlib file by using default g++ command?






share|improve this question

























    up vote
    0
    down vote

    favorite












    When I try to create a C/C++ source file



    touch test.cpp


    Usually it will generate a file which type is C source code file. But today I got a plain text file.
    enter image description here



    And I write a simple program in it like:



    #include <stdio.h>
    int main()
    printf("hello");


    Then I use G++ to compile it:



    g++ test.cpp -o test


    However, I got a sharedlib file instead of executable file.
    enter image description here



    And I can run the sharedlib file and get the correct ouput:



    ./test
    hello


    In the past, I can directly create a C++ source code file and this file type is easy to edit in vscode. But the plain text file is not comfortable for me.



    So the two questions really bother me:



    1. why my Ubuntu can not recognize C/C++ source code file correctly?

    2. why I get a sharedlib file by using default g++ command?






    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      When I try to create a C/C++ source file



      touch test.cpp


      Usually it will generate a file which type is C source code file. But today I got a plain text file.
      enter image description here



      And I write a simple program in it like:



      #include <stdio.h>
      int main()
      printf("hello");


      Then I use G++ to compile it:



      g++ test.cpp -o test


      However, I got a sharedlib file instead of executable file.
      enter image description here



      And I can run the sharedlib file and get the correct ouput:



      ./test
      hello


      In the past, I can directly create a C++ source code file and this file type is easy to edit in vscode. But the plain text file is not comfortable for me.



      So the two questions really bother me:



      1. why my Ubuntu can not recognize C/C++ source code file correctly?

      2. why I get a sharedlib file by using default g++ command?






      share|improve this question













      When I try to create a C/C++ source file



      touch test.cpp


      Usually it will generate a file which type is C source code file. But today I got a plain text file.
      enter image description here



      And I write a simple program in it like:



      #include <stdio.h>
      int main()
      printf("hello");


      Then I use G++ to compile it:



      g++ test.cpp -o test


      However, I got a sharedlib file instead of executable file.
      enter image description here



      And I can run the sharedlib file and get the correct ouput:



      ./test
      hello


      In the past, I can directly create a C++ source code file and this file type is easy to edit in vscode. But the plain text file is not comfortable for me.



      So the two questions really bother me:



      1. why my Ubuntu can not recognize C/C++ source code file correctly?

      2. why I get a sharedlib file by using default g++ command?








      share|improve this question












      share|improve this question




      share|improve this question








      edited Jun 28 at 10:35









      Kusalananda

      101k13199312




      101k13199312









      asked Jun 28 at 10:08









      pangbryant

      1




      1




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          The command touch test.cpp creates a plain text file in Ubuntu 18.04 by default as it should. Next try opening test.cpp in Gedit text editor and pasting the following code as you did:



          #include <stdio.h>
          int main()
          printf("hello");


          Save the file. Now look at the right side of the bottom panel in Gedit and you will see that the file type has changed to C++. Right-click test.cpp and select Properties and you will see that the Type has changed to C++ source code (text/x-c++src). You should have no problem running test.cpp which now has type C++ source code (text/x-c++src) in Visual Studio Code.



          If you want to get an executable/x-sharedlib file (which has a lavender diamond-shaped icon with two gears in Ubuntu 18.04) instead of an application/x-sharedlib file, then you need to create a new project for the test.cpp source code in Visual Studio Code before running it.






          share|improve this answer























          • Its type becomes c++ source code file. But when I edit it in VSCode, if I delete the #include <stdio.h> , and then I try to rewrite this code, the autocomplete doesn't have reaction. In the past, when I input #incl , the autocomplete will help me to finish #include
            – pangbryant
            Jun 28 at 10:42











          • That's an unexpected result because whenever you edit a C++ source code file in Visual Studio Code the autocomplete functionality should work properly, especially if you have already saved the C++ file at least once in Visual Studio Code.
            – karel
            Jun 28 at 10:48











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f452399%2fubuntu-18-04-think-c-c-source-code-file-is-plain-text%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          The command touch test.cpp creates a plain text file in Ubuntu 18.04 by default as it should. Next try opening test.cpp in Gedit text editor and pasting the following code as you did:



          #include <stdio.h>
          int main()
          printf("hello");


          Save the file. Now look at the right side of the bottom panel in Gedit and you will see that the file type has changed to C++. Right-click test.cpp and select Properties and you will see that the Type has changed to C++ source code (text/x-c++src). You should have no problem running test.cpp which now has type C++ source code (text/x-c++src) in Visual Studio Code.



          If you want to get an executable/x-sharedlib file (which has a lavender diamond-shaped icon with two gears in Ubuntu 18.04) instead of an application/x-sharedlib file, then you need to create a new project for the test.cpp source code in Visual Studio Code before running it.






          share|improve this answer























          • Its type becomes c++ source code file. But when I edit it in VSCode, if I delete the #include <stdio.h> , and then I try to rewrite this code, the autocomplete doesn't have reaction. In the past, when I input #incl , the autocomplete will help me to finish #include
            – pangbryant
            Jun 28 at 10:42











          • That's an unexpected result because whenever you edit a C++ source code file in Visual Studio Code the autocomplete functionality should work properly, especially if you have already saved the C++ file at least once in Visual Studio Code.
            – karel
            Jun 28 at 10:48















          up vote
          0
          down vote













          The command touch test.cpp creates a plain text file in Ubuntu 18.04 by default as it should. Next try opening test.cpp in Gedit text editor and pasting the following code as you did:



          #include <stdio.h>
          int main()
          printf("hello");


          Save the file. Now look at the right side of the bottom panel in Gedit and you will see that the file type has changed to C++. Right-click test.cpp and select Properties and you will see that the Type has changed to C++ source code (text/x-c++src). You should have no problem running test.cpp which now has type C++ source code (text/x-c++src) in Visual Studio Code.



          If you want to get an executable/x-sharedlib file (which has a lavender diamond-shaped icon with two gears in Ubuntu 18.04) instead of an application/x-sharedlib file, then you need to create a new project for the test.cpp source code in Visual Studio Code before running it.






          share|improve this answer























          • Its type becomes c++ source code file. But when I edit it in VSCode, if I delete the #include <stdio.h> , and then I try to rewrite this code, the autocomplete doesn't have reaction. In the past, when I input #incl , the autocomplete will help me to finish #include
            – pangbryant
            Jun 28 at 10:42











          • That's an unexpected result because whenever you edit a C++ source code file in Visual Studio Code the autocomplete functionality should work properly, especially if you have already saved the C++ file at least once in Visual Studio Code.
            – karel
            Jun 28 at 10:48













          up vote
          0
          down vote










          up vote
          0
          down vote









          The command touch test.cpp creates a plain text file in Ubuntu 18.04 by default as it should. Next try opening test.cpp in Gedit text editor and pasting the following code as you did:



          #include <stdio.h>
          int main()
          printf("hello");


          Save the file. Now look at the right side of the bottom panel in Gedit and you will see that the file type has changed to C++. Right-click test.cpp and select Properties and you will see that the Type has changed to C++ source code (text/x-c++src). You should have no problem running test.cpp which now has type C++ source code (text/x-c++src) in Visual Studio Code.



          If you want to get an executable/x-sharedlib file (which has a lavender diamond-shaped icon with two gears in Ubuntu 18.04) instead of an application/x-sharedlib file, then you need to create a new project for the test.cpp source code in Visual Studio Code before running it.






          share|improve this answer















          The command touch test.cpp creates a plain text file in Ubuntu 18.04 by default as it should. Next try opening test.cpp in Gedit text editor and pasting the following code as you did:



          #include <stdio.h>
          int main()
          printf("hello");


          Save the file. Now look at the right side of the bottom panel in Gedit and you will see that the file type has changed to C++. Right-click test.cpp and select Properties and you will see that the Type has changed to C++ source code (text/x-c++src). You should have no problem running test.cpp which now has type C++ source code (text/x-c++src) in Visual Studio Code.



          If you want to get an executable/x-sharedlib file (which has a lavender diamond-shaped icon with two gears in Ubuntu 18.04) instead of an application/x-sharedlib file, then you need to create a new project for the test.cpp source code in Visual Studio Code before running it.







          share|improve this answer















          share|improve this answer



          share|improve this answer








          edited Jun 28 at 11:09


























          answered Jun 28 at 10:28









          karel

          706817




          706817











          • Its type becomes c++ source code file. But when I edit it in VSCode, if I delete the #include <stdio.h> , and then I try to rewrite this code, the autocomplete doesn't have reaction. In the past, when I input #incl , the autocomplete will help me to finish #include
            – pangbryant
            Jun 28 at 10:42











          • That's an unexpected result because whenever you edit a C++ source code file in Visual Studio Code the autocomplete functionality should work properly, especially if you have already saved the C++ file at least once in Visual Studio Code.
            – karel
            Jun 28 at 10:48

















          • Its type becomes c++ source code file. But when I edit it in VSCode, if I delete the #include <stdio.h> , and then I try to rewrite this code, the autocomplete doesn't have reaction. In the past, when I input #incl , the autocomplete will help me to finish #include
            – pangbryant
            Jun 28 at 10:42











          • That's an unexpected result because whenever you edit a C++ source code file in Visual Studio Code the autocomplete functionality should work properly, especially if you have already saved the C++ file at least once in Visual Studio Code.
            – karel
            Jun 28 at 10:48
















          Its type becomes c++ source code file. But when I edit it in VSCode, if I delete the #include <stdio.h> , and then I try to rewrite this code, the autocomplete doesn't have reaction. In the past, when I input #incl , the autocomplete will help me to finish #include
          – pangbryant
          Jun 28 at 10:42





          Its type becomes c++ source code file. But when I edit it in VSCode, if I delete the #include <stdio.h> , and then I try to rewrite this code, the autocomplete doesn't have reaction. In the past, when I input #incl , the autocomplete will help me to finish #include
          – pangbryant
          Jun 28 at 10:42













          That's an unexpected result because whenever you edit a C++ source code file in Visual Studio Code the autocomplete functionality should work properly, especially if you have already saved the C++ file at least once in Visual Studio Code.
          – karel
          Jun 28 at 10:48





          That's an unexpected result because whenever you edit a C++ source code file in Visual Studio Code the autocomplete functionality should work properly, especially if you have already saved the C++ file at least once in Visual Studio Code.
          – karel
          Jun 28 at 10:48













           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f452399%2fubuntu-18-04-think-c-c-source-code-file-is-plain-text%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)