LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-10-2009, 04:24 AM   #1
monaej
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Rep: Reputation: 0
Unhappy write and run program in fedora


i have installed fedora on my system but i really dont have any idea how to write a C++ program in fedora and how to compile it .would anybody help regarding this.
 
Old 10-10-2009, 04:32 AM   #2
foodown
Member
 
Registered: Jun 2009
Location: Texas
Distribution: Slackware
Posts: 611

Rep: Reputation: 219Reputation: 219Reputation: 219
For example, I use the command:
Code:
 vi test.c
You could, of course, use emacs or any other text editor . . even a GUI text editor like kwrite or gnotepad would work.

And I write this file:
Code:
#include<stdio.h>

int
main (void) {
        printf("Hello, World!\n");
}
And then I can do this:
Code:
adam@hydra5:~$ gcc test.c -o test
adam@hydra5:~$ ./test
Hello, World!
adam@hydra5:~$
Of course, there are LOTS of options that you can pass to gcc, the GNU C Compiler . . . just do a 'man gcc' to see some of them, if not all.

If invoked as 'g++' instead of 'gcc' it will act as a C++ compiler. (You can also invoke it as just 'cc' or 'c++'.)

You don't have to operate purely in the command line like this. There are many development environments for X which are fully featured and have a lot of helpful tools. It is up to you to choose the one that you want. I don't know which is most popular these days, as I don't do a lot of coding.

Good luck!

Last edited by foodown; 10-10-2009 at 04:44 AM.
 
Old 10-10-2009, 05:15 AM   #3
guyapi
LQ Newbie
 
Registered: Sep 2009
Location: Hanover, Germany
Distribution: Fedora
Posts: 2

Rep: Reputation: 0
Hi,
you might want to try codeblocks . It's Cross platform IDE for Linux, MacOS and Windows. Since I don't use Fedora, I'm not sure if they got it in there repository...
If not you can download it from there site.

greetings, guyapi
 
Old 10-20-2009, 11:07 AM   #4
monaej
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Original Poster
Rep: Reputation: 0
can u plz let me know that how to open task manager in fedora 11?
 
Old 10-20-2009, 02:56 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by monaej View Post
can u plz let me know that how to open task manager in fedora 11?
I can't tell if this is related to your original question. If this is a new question, then please start a new thread.

Note: Please do not use texting shorthand here:
you, not u
please, not plz

And: Welcome to LQ!!
 
Old 10-20-2009, 03:58 PM   #6
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,330

Rep: Reputation: 227Reputation: 227Reputation: 227
Quote:
#include<stdio.h>

int
main (void) {
printf("Hello, World!\n");
}
WTF?
how about a code that looks, compiles and works normal?
Code:
#include <stdio.h>
int main(){
  printf("Hello, World!\n");
return 0;
}
i compiled your code in turbo C++ and heres the messages
Code:
 Compiling CH.C:
•Error CH.C 3: Declaration syntax error
•Error CH.C 3: ; Expected after "int"
•Warning CH.C 4: main(void) Declaration with no type, int assumed
•Warning CH.C 6: Function should return a value
 
Old 10-20-2009, 04:42 PM   #7
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850
Hello smeezekitty,

Quote:
Originally Posted by smeezekitty View Post
WTF?
how about a code that looks, compiles and works normal?
there's nothing wrong with the above code. It's compiled with gcc as it is. But I've never heard that Turbo-C++ runs on Linux.

Markus
 
Old 10-20-2009, 05:11 PM   #8
gzunk
Member
 
Registered: Sep 2006
Posts: 89

Rep: Reputation: 20
Smeezekitty, It's written in C. Perfectly valid C, and a C++ compiler should compile it.

Here's a C++ version for you

Code:
//===============================================
// Name        : HelloWorldCPlusPlus.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//===============================================

#include <iostream>
using namespace std;

int main() {
	cout << "Hello World!!!" << endl;
	return 0;
}
 
Old 10-20-2009, 05:18 PM   #9
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,330

Rep: Reputation: 227Reputation: 227Reputation: 227
Code:
 Compiling CPPCODE.CPP:
•Error CPPCODE.CPP 9: Unable to open include file 'IOSTREAM'
 Error CPPCODE.CPP 10: Declaration syntax error
 Error CPPCODE.CPP 13: Undefined symbol 'cout'
 Error CPPCODE.CPP 13: Undefined symbol 'endl'
if i change iostream to iostream.h and comment out using namespace std;
it compiles
 
Old 10-20-2009, 05:21 PM   #10
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850
Hi

Quote:
Originally Posted by smeezekitty View Post
if i change iostream to iostream.h and comment out using namespace std;
it compiles
we live in the year of 2009!!! This change in C++ was in 1999 as I remember.

Markus
 
Old 10-20-2009, 05:28 PM   #11
gzunk
Member
 
Registered: Sep 2006
Posts: 89

Rep: Reputation: 20
Just what version of Turbo C++ are you using? Active development of the product was stopped 15 years ago.
 
Old 10-20-2009, 05:49 PM   #12
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,330

Rep: Reputation: 227Reputation: 227Reputation: 227
i know that it is version 3.0 for dos dated 1992
i use Turbo C++ and GCC
and i make all my codes so it compiles for both

Last edited by smeezekitty; 10-20-2009 at 05:52 PM.
 
Old 10-20-2009, 06:08 PM   #13
gzunk
Member
 
Registered: Sep 2006
Posts: 89

Rep: Reputation: 20
Quote:
Originally Posted by smeezekitty View Post
i know that it is version 3.0 for dos dated 1992
i use Turbo C++ and GCC
and i make all my codes so it compiles for both
Umm, I really wouldn't. Why don't you use Eclipse CDT + MinGW or Cygwin for your windows development? Then at least you'd have an up to date C++ compiler that complies with the C++98 ISO standard
 
Old 10-20-2009, 06:11 PM   #14
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,330

Rep: Reputation: 227Reputation: 227Reputation: 227
Quote:
Originally Posted by gzunk View Post
Umm, I really wouldn't. Why don't you use Eclipse CDT + MinGW or Cygwin for your windows development? Then at least you'd have an up to date C++ compiler that complies with the C++98 ISO standard
i use that too but some programs need to run on my dos 486 with 12 MB ram
 
Old 10-20-2009, 06:18 PM   #15
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,330

Rep: Reputation: 227Reputation: 227Reputation: 227
@original poster sorry for the thread hijack, but return type should be on the same line and needed to make that point
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Unable to compile and run a C program in fedora dhivyababulal Linux - Newbie 3 09-22-2008 12:10 PM
how to run a java program in fedora 8 av.dubey Linux - Newbie 7 05-28-2008 09:19 PM
how to write a batch file to make a program run during boot up in windows??? b0nd Programming 7 09-04-2006 07:16 AM
Viewing program messages when program isn't run from command line? Locura Linux - Software 1 09-27-2003 09:19 AM


All times are GMT -5. The time now is 12:48 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration