LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 05-22-2010, 01:46 AM   #1
iqra
Member
 
Registered: May 2010
Posts: 34

Rep: Reputation: 15
i want to run c++ program on fedora and it give errors of its header files.


hii,

i have a c++ program and i tried to run it using gcc command and it gives header files error i got the header file now but dont know where to place those files?

can any one got the idea??? we could not place header files in usr/include folder!

Regards
Iqra
 
Old 05-22-2010, 03:23 AM   #2
Dogs
Member
 
Registered: Aug 2009
Location: Houston
Distribution: Slackware 13.37 x64
Posts: 105

Rep: Reputation: 25
use g++ instead
 
Old 05-22-2010, 04:03 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Like @ Dogs says : use g++ instead.

gcc is for c code. The g++ / c++ command is for c++ code.

..
 
Old 05-22-2010, 09:56 AM   #4
iqra
Member
 
Registered: May 2010
Posts: 34

Original Poster
Rep: Reputation: 15
@ Dogs & knudfl
thanx!

i tried like this but actually those header files are i guess not built in.. one of them i got from net but i dont know in which folder to put that.... like we do in Turbo C (in windows) we put header files in INCLUDE folder...

if m using g++ what will be the command to compile and run the program?
same like GCC (gcc prog.c) ??
 
Old 05-22-2010, 10:03 AM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Option 1.: Same location as code.cc : Use : #include "header.h"

Option 2.: /usr/local/include/ : Use : #include <header.h>

".." is for local headers, <..> for headers in a system path.

.. ..

Last edited by knudfl; 05-22-2010 at 10:04 AM.
 
Old 05-22-2010, 01:44 PM   #6
Dogs
Member
 
Registered: Aug 2009
Location: Houston
Distribution: Slackware 13.37 x64
Posts: 105

Rep: Reputation: 25
Note that the .h extension in the #include <> line is deprecated (no longer used)

just do <headername>
not <headername.h>
 
Old 05-22-2010, 08:00 PM   #7
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi, iqra -

1. First, you need to install G++. This should include the standad headers. I would recommend this command (which includes all the C/C++ stuff you're likely to need sooner or later):
Quote:
yum -y install gcc gcc-c++ kernel-devel
2. You would use "gcc" to compile a C program:
Quote:
1. vi hello.c
Code:
#include <stdio.h>

int
main (int argc, char *argv[])
{
  printf ("Hello world!\n");
  return 0;
}
2. gcc -o hello hello.c

3. ./hello
3. You would do the same for C++, except (as the others all recommended), you would use the "g++" command instead.

'Hope that helps!
 
Old 05-23-2010, 01:07 AM   #8
iqra
Member
 
Registered: May 2010
Posts: 34

Original Poster
Rep: Reputation: 15
@ Above All

thank you for your help! :-)
 
  


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
Help in header files needed to run a C code using gcc/g++. BlueSkull Programming 3 12-10-2009 02:49 AM
I need a way to give several users permissions to run a single program Thaidog Linux - Desktop 1 01-04-2009 02:06 AM
including /usr/include/linux/ header files throwing errors in SLES 10.2 deedhnd Linux - Server 9 08-19-2008 08:08 AM
C++ program using C header system files yhus Programming 1 02-15-2008 06:14 PM
while compiling c programme it's showing errors in header files mprabu20 Programming 1 04-08-2006 02:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

All times are GMT -5. The time now is 05:49 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
Open Source Consulting | Domain Registration