Hello :-)

I have installed Fedora Core 4 and we learn in college C++ .
where can i find a C++ author and compiler for Fedora Core 4?

Thank you

Recommended Answers

All 5 Replies

Hello :-)

I have installed Fedora Core 4 and we learn in college C++ .
where can i find a C++ author and compiler for Fedora Core 4?

Thank you

C++ Author : I dont know what you mean by this.
compiler : Fedora Core 4 comes with the g++ compiler which can Compile C++ programs

where is it located , the compiler in the Fedora System .... i cant find it

where is it located , the compiler in the Fedora System .... i cant find it

I dont know where it is located. Maybe in the usr/bin directory. No way of checking since I dont have Linux installed.

Anyway the location is not that important. Usually if you install Fedora as "workstation" then g++ is installed by default.

set up a convenient data directory in which to place your programs. Create a file named temp.cpp with this content:

#include <iostream>
int main()
{
	std::cout << "Hello World!" << std::endl;
	return 0;
}

Move to the directory in which temp.cpp is located, and type this:

g++ temp.cpp

If you have not made any errors, the program will compile uneventfully, and a program file named a.out will be created in the same directory.

To execute your program, type ./a.out and press Enter. The program should run, and print Hello world! on the display.

This series of actions confirms that you have the g++ compiler and it is working properly.


[EDIT]
Typing g++ -v will give you the version of g++ if it is installed.

When you have more than one program in one directory, you usually don't want to always use the executable name a.out. You can pass the -o option to g++ to specify the output file:

$ cat > randword.cpp
#include <iostream>
#include <cstdlib>
#include <ctime>

using std::cout;

int main(void) {
    srand(time(0));

    cout << (rand() % 2 ? "yes" : "no") << std::endl;

    return 0;
}

$ g++ randword.cpp -o randword

$ ./randword
yes
$ ./randword
no
$

To enable many warnings, use the following g++ command line:

$ g++ -W -Wall -ansi -pedantic -O2 hello.cpp -o hello

When you have more than one program in one directory, you usually don't want to always use the executable name a.out. You can pass the -o option to g++ to specify the output file:

$ cat > randword.cpp
#include <iostream>
#include <cstdlib>
#include <ctime>

using std::cout;

int main(void) {
    srand(time(0));

    cout << (rand() % 2 ? "yes" : "no") << std::endl;

    return 0;
}

$ g++ randword.cpp -o randword

$ ./randword
yes
$ ./randword
no
$

To enable many warnings, use the following g++ command line:

$ g++ -W -Wall -ansi -pedantic -O2 hello.cpp -o hello

The above is correct, but better not to overwhelm a newbie with complex compiler switches like that IMHO.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.