LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-07-2006, 09:17 PM   #1
graciejj_82
Member
 
Registered: Feb 2006
Distribution: Fedora 2
Posts: 63

Rep: Reputation: 15
C++ compiling in mandrake 10.1


I'm trying to learn c++. I've wrote a small little "Hello Worl" and I'm trying to compile it. I've used the commands "c++" and "g++" but they both say they don't exist.

I can use the command "cpp -o test cpp.cpp" and it tells me
cpp.cpp:4:20: iostream: No such file or directory
cpp.cpp:10:1: warning: no newline at end of file


I wrote the code in kwrite, and it is as follows.
//C++ Program
//Writen by:Michael

#include <iostream.h>

int main()
{
cout << "Hello World"\n<<;
return 0;
}


I just recently switched to mandrake from fedora 2, and I could make it work fine in Fedora, but it doesn't want to cooperate now. Please help.

Thanks alot,
Michael
 
Old 03-08-2006, 01:33 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
cpp isn't a compiler, it's the preprocessor. Are you sure you have gcc-c++ (or whatever the package is called under Mandrake) installed?
 
Old 03-08-2006, 03:21 AM   #3
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
As mentioned by Nylex, you need gcc-g++ and to compile your app you would do
Code:
$g++ program.cpp -o program
Your code should be something like this
Code:
//C++ Program
//Writen by:Michael

#include <iostream>
using namespace std;
int main()
{
    cout << "Hello World\n";
    return 0;
}
The reason is that declarion of headers has changed slightly in the latest C++ standards.
 
Old 03-08-2006, 07:46 AM   #4
graciejj_82
Member
 
Registered: Feb 2006
Distribution: Fedora 2
Posts: 63

Original Poster
Rep: Reputation: 15
So if I can get "gcc" or "g++" on my pc, I won't even use "cpp"? And if so, assuming its not on my install cds, where would i get it??
 
Old 03-08-2006, 09:58 AM   #5
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
gcc-g++ is on your installation disks so you can install it using the software module in the Mandriva Control Center. You don't use cpp, you use gcc or g++ to compile you apps.
 
Old 03-08-2006, 04:55 PM   #6
graciejj_82
Member
 
Registered: Feb 2006
Distribution: Fedora 2
Posts: 63

Original Poster
Rep: Reputation: 15
I checked my install cd's, and I don't see them. I did find some stuff for perl, but havn't looked at it.

I do have some fedora 2 cd's, and I know i've used some c++ in fedora, could I install off of those cd's?
 
Old 03-08-2006, 05:05 PM   #7
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
GCC and GCC-C++ are on the Mandriva installation discs. You need to install your packages using the Mandriva Control Center's software module i.e. Kmenu -> System -> Configuration -> Configure Your Computer. Enter roots password when prompted, then go to Look at Installable Software and Install Software. Search for gcc and a list of gcc related packages will be shown. Tick those you wish to install and insert your installation disc when prompted.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with compiling in Mandrake 10.1 greentooth Linux - Software 12 07-01-2005 10:34 AM
Compiling programs? [Mandrake] TiRaK Linux - Newbie 2 12-22-2003 02:36 AM
compiling the kernel with mandrake 9.2 Zvi Linux - Software 1 12-03-2003 07:10 AM
Compiling Problems on Mandrake 9.0 johan the olive Linux - Software 9 02-27-2003 08:37 PM
Compiling Arts-1.1 on Mandrake 9.0? harlom Linux - Software 17 01-24-2003 12:01 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration