On this TechRepublic Make Tech Work video, Jack Wallen exhibits you the step-by-step technique of compiling a C++ program on Linux, utilizing Ubuntu Desktop 23.04 for his demo.
I’m going to indicate you methods to compile a C++ program on Linux. I’ll show it on Ubuntu Desktop 23.04, I’ll use the tried and true Hiya, World! app for instance.
The very first thing you could do is set up the required software program to help you construct C++ packages. To do this, open a terminal window and challenge the command sudo apt-get set up build-essential -y. For those who’re on a Fedora-based distribution, that command could be sudo dnf set up gcc-c++ -y.
Now that you’ve got the required instruments put in, let’s create the Hiya, World! file with the command nano hey.cpp. In that file, paste the content material proven within the video. When you’ve pasted the content material into the file, put it aside with the Ctrl-X shortcut.
Subsequent, we have now to compile this system with the command g++ hey.cpp -o hey. As a result of that is such a small program, it ought to compile virtually instantly. One of many good issues about this course of is that, upon compilation, your program will robotically have executable permissions, so there’s nothing to vary on this regard.
Then, you’ll be able to run this system with the command ./hey, which can print out Hiya World! in your terminal. And that’s all there may be to compiling C++ packages in Linux.
Right here is the code for Hiya World:
#embrace <iostream>
int essential() {
std::cout << "Hiya World!";
return 0;
}
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the most recent tech recommendation for enterprise professionals from Jack Wallen.