A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/linux-unix/compiling-with-g-plus-plus/ below:

Compiling with g++ - GeeksforGeeks

Compiling with g++

Last Updated : 08 Apr, 2024

g++ command is a GNU c++ compiler invocation command, which is used for preprocessing, compilation, assembly and linking of source code to generate an executable file. The different "options" of g++ command allow us to stop this process at the intermediate stage. 
 

g++ --version
CPP
// hello.cpp file
#include <iostream>
int main()
{
    std::cout << "Hello Geek\n";
    return 0;
}
g++ hello.cpp


This compiles and links hello.cpp to produce a default target executable file a.out in present working directory. To run this program, type ./a.out where ./ represents present working directory and a.out is the executable target file.
 

./a.out
g++ -S hello.cpp

g++ -c hello.cpp

g++ -o main.exe hello.cpp
CPP
// hello.cpp file
#include "helloWorld.h"
#include <iostream>
int main()
{
    std::cout << "Hello Geek\n";
    helloWorld();
    return 0;
}
CPP
// helloWorld.cpp file
#include <iostream>
void helloWorld()
{
    std::cout << "Hello World\n";
}
CPP
// helloWorld.h file
void helloWorld();
g++ -c helloWorld.cpp hello.cpp
g++ -o main.exe helloWorld.o hello.o
./main.exe
CPP
// hello.cpp file
#include <iostream>
int main()
{
    int i;
    std::cout << "Hello Geek\n";
    return 0;
}
g++ -Wall hello.cpp



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4