954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Compiling in Fedora Core 4

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

YoTaMiX
Light Poster
38 posts since Jan 2006
Reputation Points: 10
Solved Threads: 0
 

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

WolfPack
Postaholic
Moderator
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
 

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

YoTaMiX
Light Poster
38 posts since Jan 2006
Reputation Points: 10
Solved Threads: 0
 
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.

WolfPack
Postaholic
Moderator
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
 

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
dwks
Posting Whiz in Training
269 posts since Nov 2005
Reputation Points: 185
Solved Threads: 28
 

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.

WolfPack
Postaholic
Moderator
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You