Coding in linux environment

Operating System

As mentioned above, we are gonna be using an OS, which comes under the Linux Distro. There are many popular distro out there, but for starters, Ubuntu is recommended, Kali and Arch Linux are for advance user.
If you are a Windows lover, then stick to Windows 7 or above versions.

Text Editor

Lets set up Geany

Installation

First thing first, we need to install it. You are open to install it either from Ubuntu Software or from the Official Geany Website.
You can also install using the terminal, copy the commands in your terminal:
For Ubuntu/ Debian:-
sudo apt-get install geany
For Fedora:
sudo dnf install geany
For CentOS:
sudo snap install geany-gtk —edge
You can also install plugins

Configure

Once you are done with installation, you can find Geany, using the search bar.

KeyBindings

  1. Edit->Preferences->Keybindings
  2. Head to focus.
  3. Now change the following:
    1. Switch to Editor-> F1
    2. Switch to VTE-> F2

    Terminal

    Build and Compile

    1. First create any C++ file by typing anything in the text editor, and save it by cntrl+s, with a .cpp extension
    2. Head to Build->Set Build Commands
    3. Copy the following flags with the corresponding commands:-
      1. Compile (F8): g++ -std=c++17 -Wshadow -Wall -o «%e» «%f» -O2 -Wno-unused-result
      2. Build (F9): g++ -std=c++17 -Wshadow -Wall -o «%e» «%f» -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG

      You may get compilation error, if so, then try changing from C++17 to C++14, or remove the two sanitizers.

      This is the basic set up for Competitive Programming in a Linux Environment, you can obviously set up another text editor like Sublime, with the other settings as well. I will make a post on that very soon.

      Alt Text

      Credits: The flags that I have used here, has been provided by Errichto, Link to GitHub
      Thank You!
      After complete setup, the environment should look like this:

      Источник

      Best IDE’s for Linux

      I love coding, and ever since the introduction of Integrated Development Environment, also known as IDE, coding has become more of a fun task than a tedious one. IDE’s or Source Code Editors take the task of programming and coding to the next level and make great building applications much easier.

      IDE’s come with many features and plug-ins that help the programmers code the program error or bug-free. There are IDE’s available on Linux and its popularly used distros such as Ubuntu, but I am going to introduce you to the best 10 IDE’s.

      The IDE’s listed below are compatible with coding in various widely-used programming languages like C, C++, and Python. So, let’s get started.

      1. Atom

      Atom is the first of its kind text editor or integrated development environment which is completely hackable. It is a cross-platform editor which comes with a built-in package manager. It offers a modern user interface that is very easy to use, and programmers will find this very easy to work on.

      It also ships in with an auto-completion feature that helps programmers write code faster with smart and flexible autocomplete. You can also split its interface into multiple panes to compare and edit code. It also comes with a find and replace feature that helps you find, preview, and replace text as you type in or across all the projects you are working on.

      The interface ships with 4 user interfaces and 8 syntax themes pre-installed in dark and light modes.

      2. Visual Studio Code

      Everyone knows Visual Studio Code which Microsoft develops for Windows. The reason why this features my list is that it is still one of the best out there when it comes to source code editing and application programming.

      It is not limited to Windows, as it also comes with full support for Linux and its distro’s such as Ubuntu. It is an advanced code editor which offers all the features programmer or coder expects from IDE. One of the reasons programmers and popular amongst them still use it is that it comes with various extensions that can be used to enhance the features of the IDE.

      Visual Studio Code is an open-source tool and is also available for free for everyone. Apart from Windows and Linux, it also works effortlessly on macOS as it is a cross-platform IDE.

      3. Sublime Text

      Sublime Text is one of the oldest Integrated Development Environment supporting many programming and markup languages. It comes with a slick user interface and extraordinary features, making it a popular IDE among programmers and developers.

      The latest release Sublime Text 4, comes bundled with new features and enhancements such as GPU rendering for fluid UI experience, support for Apple Silicon processors and Linux ARM64 builds, tab multi-select, context-aware auto-complete, typescript, jsx, and tsx support, improved syntax highlighting engine and fully revamped user interface.

      It is completely free to download an integrated development environment.

      4. Spacemacs

      Spacemacs is a community-driven configuration framework for GNU Emacs. It collaborates with Emacs and Vim to offer a great programming and coding environment for developers.

      Emacs is a more polished version focused on ergonomics, mnemonics, and consistency. It comes with a community-driven configuration that provides curated packages tuned by power users, and bugs are fixed immediately with quick updates.

      It is a cross-platform IDE with Windows, MacOS, and Linux support.

      5. Brackets

      Brackets is an open-source integrated development environment focusing primarily on web development. It is a cross-platform code editor developed by Adobe Systems. It is a modern editor with a beautiful and easy-to-use interface.

      As mentioned earlier, it is dedicated to web development; front-end developers will love working on this IDE. It is a very powerful editor with features like syntax highlighting, inline editors, live preview, and preprocessor support.

      It is a lightweight yet powerful code editor that works effortlessly on modern and older machines.

      6. Eclipse

      Eclipse is one of the most popular IDEs among software and web developers. We can even call it a Java development IDE, as it comes with the latest Java 17 and JUnit 5.8 support with necessary development tools.

      Thanks to excellent community backing, it comes with stable performance out of the box. Apart from Java, Eclipse also supports other widely used programming languages like Python, C, C++, JavaScript, PHP, and many more.

      It is one of the most modern and advanced integrated development environments available for Linux and its distros such as Ubuntu and LinuxMint.

      It is a free and open-source IDE that offers great front-end development features and tools.

      7. Apache Netbeans

      Apache Netbeans is a cross-platform integrated development environment for Java; It offers editors, wizards, and templates to help you create applications and web applications in various languages such as Java, PHP, HTML 5, CSS, and many more.

      It is a cross-platform IDE; it can be installed easily on any operating system running Java, such as Windows, Mac OSX, and Linux. Write once and execute anywhere features work effortlessly with NetBeans.

      It also offers features like source code highlighting both syntactically and semantically and powerful tools.

      8. Intellij IDEA

      Developed by JetBrains, Intellij IDEA is an integrated development environment written in Java. It is an excellent IDE for developing computer software. It offers features like instant and clever code completion, on-the-fly code analysis, and reliable refactoring tools which help maximize developer productivity.

      It offers a great end-user experience out of the box with various supported languages and frameworks. It is a modern IDE that sports a modern-looking user interface that is very easy to use even for first-time users. It is a very popular IDE among JAVA developers.

      So, these are the best-integrated development environment for web and application developers using Linux and its distros such as Ubuntu and LinuxMint. All the IDEs listed here are ideal for new as well as professional programmers and developers.

      About the author

      Swapnil Tirthakar

      A Software Engineer who loves football and passionate about traveling. I often spend my free time playing with gadgets and exploring new possibilities in tech world. I am Linux enthusiast and have about 6 years of experience in web development. I have good command on Python, Java, SQL and system security.

      Источник

      How to Write, Compile and Run a C Program in Ubuntu and Other Linux Distributions [Beginner’s Tip]

      Running C program in Linux command line is not that difficult. Running it in a code editor like Visual Studio Code is even easier. Learn both methods.

      How do you program in C on Linux? It is indeed very easy and consists of three simple steps. Step 1: Write your program and save the file with a .c extension. For example, my_program.c. Step 2: You compile the program and generate the object file using gcc compiler in a terminal like this:

      gcc -o my_program my_program.c

      Running a C Program in Linux using gcc

      This was just a quick summary of how to compile and run a C program in Linux. If you are new to either C or Linux, I’ll show these steps in detail to make you comfortable coding C programs in a Linux environment. I’ll discuss how to run C programs in a Linux terminal and a code editor.

      Method 1: How to run C programs in a Linux terminal

      In order to run a C program in Linux, you need to have a C compiler present on your systems. The most popular compiler is gcc (GNU Compiler Collection). You can install gcc using your distribution package manager. In Debian and Ubuntu-based Linux distributions, use the apt command:

      Switch to the directory where you have kept your C program (or provide the path) and then generate the object file by compiling the program:

      gcc -o my_program my_program.c

      Keep in mind that it is optional to provide the output object file (-o my_program). If you won’t do that, an object file named a.out will be automatically generated. But this is not good because it will be overwritten for each C program and you won’t be able to know which program the a.out object file belongs to. Once your object file is generated, run it to run the C program. It is already executable. Simply use it like this:

      And it will display the desired output if your program is correct. As you can see, this is not very different from running C++ programs in Linux.

      Every time you make a change in your program, you have to compile it first and then run the generated object file to run the C program.

      Method 2: How to run C programs in Linux using a code editor like Visual Studio Code

      C program editing in Visual Studio Code

      Not everyone is comfortable with the command line and terminal and I totally understand that. You can use a proper C/C++ IDE like Eclipse or Code Blocks but they are often too heavy programs and more suitable for large projects. I recommend using an open-source code editor like Visual Studio Code or Atom. These are basically text editors and you can install add-ons to compile and run programs directly from the graphical code editor. I am using Visual Studio Code editor in this example. It’s a hugely popular open-source code editor from Microsoft. First thing first, install Visual Studio Code in Ubuntu from the software centre. For other distributions, please check your Linux distribution’s package manager or software centre. You may also check the official website for more information. Start Visual Studio Code and open/create a project and create your C program here. I am using a sample Hello World program. You must ensure the gcc compiler is installed on your Linux system.

      Next, you would want to use an extension that allows you to run the C code. Microsoft may prompt you for installing its own extension for the C/C++ programs but it is complicated to set up and hence I won’t recommend it. Instead, I suggest using the Code Runner extension. It’s a no-nonsense extension and you can run C and C++ code easily without additional configuration. Go to the Extensions tab, search for ‘Code Runner,’ and install it. Installing Code Runner extension in Visual Studio CodeRestart Visual Studio Code. Now, you should be able to run the C code by using one of the following ways:

      • Using the shortcut Ctrl+Alt+N.
      • Press F1 and then select or type Run Code.
      • Right-click the text editor and click Run code from the context menu.

      Right -click the program file that you want to run and then press

      When you run the program, it is compiled automatically and then run. You can see the output in the terminal that is opened at the bottom of the editor. What could be better than this?

      Program output is displayed in the bottom section of the Visual Studio Code editor

      Which method do you prefer?

      If you prefer a video to learn about installing and running C programs in Linx, check out the below Video tutorial.

      Источник

      Читайте также:  Локальная сеть линукс windows
Оцените статью
Adblock
detector