LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 07-04-2012, 04:50 AM   #1
amitback
LQ Newbie
 
Registered: Jun 2012
Posts: 8

Rep: Reputation: Disabled
Unhappy header files in c++ programming


hello frnds,
I have just installed BACKTRACK linux on my computer.
I use BACKTRACK for my c++ programming practice but my problem is I am not able to include the user created header files in my program.
Usually I create 2 header files one in which I declare the functions and other in which I define those. I save those files(filename.h ) in root folder.
and in .cpp file I use #include"filenamae.h" statement so that those files will be included in main()
but I am getting error "a3.cpp:2:14: error: filename: No such file or directory"
pls help!!
 
Old 07-04-2012, 04:55 AM   #2
kauuttt
Member
 
Registered: Dec 2008
Location: Atlanta, GA, USA
Distribution: Ubuntu
Posts: 135

Rep: Reputation: 26
#include"filenamae.h"

Is it a typo? Or because of this you are seeing the issue?

-kd
 
Old 07-04-2012, 04:58 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
what do you mean by root folder? Can you please show us a tree how your files are organized! Also how did you try to build your app? What was the command you executed? (I hope you do not use root user to do this)

Last edited by pan64; 07-04-2012 at 05:00 AM. Reason: typo
 
Old 07-04-2012, 04:59 AM   #4
amitback
LQ Newbie
 
Registered: Jun 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by kauuttt View Post
#include"filenamae.h"

Is it a typo? Or because of this you are seeing the issue?

-kd
its certainly not a typo!
 
Old 07-04-2012, 05:06 AM   #5
amitback
LQ Newbie
 
Registered: Jun 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by pan64 View Post
what do you mean by root folder? Can you please show us a tree how your files are organized! Also how did you try to build your app? What was the command you executed? (I hope you do not use root user to do this)
root folder means when i open home folder from places i can view that file..
and I am logged in as root!! is there any problem bcoz i dnt have any imp data in my hdd
 
Old 07-04-2012, 05:09 AM   #6
kauuttt
Member
 
Registered: Dec 2008
Location: Atlanta, GA, USA
Distribution: Ubuntu
Posts: 135

Rep: Reputation: 26
Quote:
Originally Posted by amitback View Post
its certainly not a typo!
Didn't get your point clearly..

is the name of the file filenamae.h? and still you are not getting it while compiling?

In that case, can you please run "tree" and post it please..need to know the directory structure what you are using.
 
Old 07-04-2012, 05:12 AM   #7
amitback
LQ Newbie
 
Registered: Jun 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by kauuttt View Post
Didn't get your point clearly..

is the name of the file filenamae.h? and still you are not getting it while compiling?

In that case, can you please run "tree" and post it please..need to know the directory structure what you are using.
.
├── a1.cpp
├── a1.cpp~
├── a2.cpp
├── a2.cpp~
├── #a3.cpp#~
├── a3.cpp
├── a3.cpp~
├── amit
│** ├── Biomedical Instrumentation.pdf
│** ├── Civil IV.pdf
│** ├── Civil VIII.pdf
│** ├── Civil VI.pdf
│** ├── Comp IV.pdf
│** ├── Computer Engineering.pdf
│** ├── Comp VIII.pdf
│** ├── Comp VI.pdf
│** ├── Construction management.pdf
│** ├── Control Systems.pdf
│** ├── Design Engineering.pdf
│** ├── Digital Systems.pdf
│** ├── Elec IV.pdf
│** ├── Elec VI.pdf
│** ├── Environmental water resourses.pdf
│** ├── E&TC IV.pdf
│** ├── E&TC VIII.pdf
│** ├── E&TC VI.pdf
│** ├── Geotechnical Engineering.pdf
│** ├── Heat Power Engineering.pdf
│** ├── Instru IV.pdf
│** ├── Instru VIII.pdf
│** ├── Instru VI.pdf
│** ├── IT IV.pdf
│** ├── IT VIII.pdf
│** ├── IT VI.pdf
│** ├── Manufacturing Engineering and Automation.pdf
│** ├── Mechatronics.pdf
│** ├── Mech IV.pdf
│** ├── Mech VIII.pdf
│** ├── Mech VI.pdf
│** ├── Meta IV.pdf
│** ├── Meta VI.pdf
│** ├── Physical Metallurgy.pdf
│** ├── Power Systems.pdf
│** ├── Process Instrumentation.pdf
│** ├── Process Metallurgy.pdf
│** ├── prod IV.pdf
│** ├── prod VI.pdf
│** ├── Sem II Applied Science.pdf
│** ├── Signal Processing.pdf
│** ├── Structural engg.pdf
│** ├── Town and Country Planning.pdf
│** ├── VLSI and Embedded System.pdf
│** └── Wired & Wireless Communication.pdf
├── A.PRACTICAL.GUIDE.TO.UBUNTU.LINUX.3rd.EDITION.EBOOK.PAPU.pdf
├── bayago bayago.mp3
├── COEP_Registration_Process_June25_2012.pdf
├── dec.h
├── def.h
├── Desktop
│** ├── A.PRACTICAL.GUIDE.TO.UBUNTU.LINUX.3rd.EDITION.EBOOK.PAPU.pdf
│** ├── backtrack-install.desktop
│** ├── Let Us C - Yashwant Kanetkar.pdf
│** └── The Basics of Hacking and Penetration Testing Ethical Hacking and Penetration Testing Made Easy
│** ├── Openmirrors.com__The_Basics_of_Hacking_and_Penetration_Testing__Ethical_Hacking_and_Penetration_Test ing_Made_Easy.pdf
│** └── Torrent downloaded from Demonoid.me.txt
├── Downloads
│** └── Branch_Change_Notice.pdf
├── emma1.jpg
├── firefox
│** ├── application.ini
│** ├── blocklist.xml
│** ├── chrome
│** │** └── icons
│** │** └── default
│** │** ├── default16.png
│** │** ├── default32.png
│** │** └── default48.png
│** ├── chrome.manifest
│** ├── components
│** │** ├── binary.manifest
│** │** ├── libbrowsercomps.so
│** │** ├── libdbusservice.so
│** │** ├── libmozgnome.so
│** │** └── libnkgnomevfs.so
│** ├── crashreporter
│** ├── crashreporter.ini
│** ├── crashreporter-override.ini
│** ├── defaults
│** │** └── pref
│** │** └── channel-prefs.js
│** ├── dependentlibs.list
│** ├── dictionaries
│** │** ├── en-US.aff
│** │** └── en-US.dic
│** ├── extensions
│** │** └── {972ce4c6-7e08-4474-a285-3208198ce6fd}
│** │** ├── icon.png
│** │** ├── install.rdf
│** │** └── preview.png
│** ├── firefox
│** ├── firefox-bin
│** ├── icons
│** │** ├── mozicon128.png
│** │** └── updater.png
│** ├── jsloader
│** │** └── resource
│** ├── libfreebl3.chk
│** ├── libfreebl3.so
│** ├── libmozalloc.so
│** ├── libmozsqlite3.so
│** ├── libnspr4.so
│** ├── libnss3.so
│** ├── libnssckbi.so
│** ├── libnssdbm3.chk
│** ├── libnssdbm3.so
│** ├── libnssutil3.so
│** ├── libplc4.so
│** ├── libplds4.so
│** ├── libsmime3.so
│** ├── libsoftokn3.chk
│** ├── libsoftokn3.so
│** ├── libssl3.so
│** ├── libxpcom.so
│** ├── libxul.so
│** ├── mozilla-xremote-client
│** ├── omni.ja
│** ├── platform.ini
│** ├── plugin-container
│** ├── precomplete
│** ├── removed-files
│** ├── run-mozilla.sh
│** ├── searchplugins
│** │** ├── amazondotcom.xml
│** │** ├── bing.xml
│** │** ├── eBay.xml
│** │** ├── google.xml
│** │** ├── twitter.xml
│** │** ├── wikipedia.xml
│** │** └── yahoo.xml
│** ├── Throbber-small.gif
│** ├── updater
│** ├── updater.ini
│** └── update-settings.ini
├── linux command learning.pdf
└── qBT_dir
this is the tree ...
and the names of files are dec.h and def.h!! but how can name of file matter(if it is typed correctly in each step??
 
Old 07-04-2012, 05:21 AM   #8
kauuttt
Member
 
Registered: Dec 2008
Location: Atlanta, GA, USA
Distribution: Ubuntu
Posts: 135

Rep: Reputation: 26
I hope the source files of yours are - a*.cpp.
If the src file and the .h files are there in the same directory, then a simple gcc a*.cpp should be enough!
Please cross check your header inclusion; presence of the files; makefiles (if any) to wipe out any probable human error..
 
Old 07-04-2012, 05:24 AM   #9
amitback
LQ Newbie
 
Registered: Jun 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by kauuttt View Post
I hope the source files of yours are - a*.cpp.
If the src file and the .h files are there in the same directory, then a simple gcc a*.cpp should be enough!
Please cross check your header inclusion; presence of the files; makefiles (if any) to wipe out any probable human error..
can u pls tell me what is use of "make file" statement I have read about it in many posts but I dont knw anything about it
how can I check whether they are in same directory or not?
you may seem questions very silly but i am complete newbie!!

Last edited by amitback; 07-04-2012 at 05:29 AM.
 
Old 07-04-2012, 06:17 AM   #10
anshuman84
Member
 
Registered: May 2008
Location: Bangalore
Posts: 31

Rep: Reputation: 6
Quote:
Originally Posted by amitback View Post
.
├── a1.cpp
├── a1.cpp~
├── a2.cpp
├── a2.cpp~
├── #a3.cpp#~
├── a3.cpp
├── a3.cpp~
├── amit
│** ├── Biomedical Instrumentation.pdf
│** ├── Civil IV.pdf
│** ├── Civil VIII.pdf
│** ├── Civil VI.pdf
│** ├── Comp IV.pdf
│** ├── Computer Engineering.pdf
│** ├── Comp VIII.pdf
│** ├── Comp VI.pdf
│** ├── Construction management.pdf
│** ├── Control Systems.pdf
│** ├── Design Engineering.pdf
│** ├── Digital Systems.pdf
│** ├── Elec IV.pdf
│** ├── Elec VI.pdf
│** ├── Environmental water resourses.pdf
│** ├── E&TC IV.pdf
│** ├── E&TC VIII.pdf
│** ├── E&TC VI.pdf
│** ├── Geotechnical Engineering.pdf
│** ├── Heat Power Engineering.pdf
│** ├── Instru IV.pdf
│** ├── Instru VIII.pdf
│** ├── Instru VI.pdf
│** ├── IT IV.pdf
│** ├── IT VIII.pdf
│** ├── IT VI.pdf
│** ├── Manufacturing Engineering and Automation.pdf
│** ├── Mechatronics.pdf
│** ├── Mech IV.pdf
│** ├── Mech VIII.pdf
│** ├── Mech VI.pdf
│** ├── Meta IV.pdf
│** ├── Meta VI.pdf
│** ├── Physical Metallurgy.pdf
│** ├── Power Systems.pdf
│** ├── Process Instrumentation.pdf
│** ├── Process Metallurgy.pdf
│** ├── prod IV.pdf
│** ├── prod VI.pdf
│** ├── Sem II Applied Science.pdf
│** ├── Signal Processing.pdf
│** ├── Structural engg.pdf
│** ├── Town and Country Planning.pdf
│** ├── VLSI and Embedded System.pdf
│** └── Wired & Wireless Communication.pdf
├── A.PRACTICAL.GUIDE.TO.UBUNTU.LINUX.3rd.EDITION.EBOOK.PAPU.pdf
├── bayago bayago.mp3
├── COEP_Registration_Process_June25_2012.pdf
├── dec.h
├── def.h
├── Desktop
│** ├── A.PRACTICAL.GUIDE.TO.UBUNTU.LINUX.3rd.EDITION.EBOOK.PAPU.pdf
│** ├── backtrack-install.desktop
│** ├── Let Us C - Yashwant Kanetkar.pdf
│** └── The Basics of Hacking and Penetration Testing Ethical Hacking and Penetration Testing Made Easy
│** ├── Openmirrors.com__The_Basics_of_Hacking_and_Penetration_Testing__Ethical_Hacking_and_Penetration_Test ing_Made_Easy.pdf
│** └── Torrent downloaded from Demonoid.me.txt
├── Downloads
│** └── Branch_Change_Notice.pdf
├── emma1.jpg
├── firefox
│** ├── application.ini
│** ├── blocklist.xml
│** ├── chrome
│** │** └── icons
│** │** └── default
│** │** ├── default16.png
│** │** ├── default32.png
│** │** └── default48.png
│** ├── chrome.manifest
│** ├── components
│** │** ├── binary.manifest
│** │** ├── libbrowsercomps.so
│** │** ├── libdbusservice.so
│** │** ├── libmozgnome.so
│** │** └── libnkgnomevfs.so
│** ├── crashreporter
│** ├── crashreporter.ini
│** ├── crashreporter-override.ini
│** ├── defaults
│** │** └── pref
│** │** └── channel-prefs.js
│** ├── dependentlibs.list
│** ├── dictionaries
│** │** ├── en-US.aff
│** │** └── en-US.dic
│** ├── extensions
│** │** └── {972ce4c6-7e08-4474-a285-3208198ce6fd}
│** │** ├── icon.png
│** │** ├── install.rdf
│** │** └── preview.png
│** ├── firefox
│** ├── firefox-bin
│** ├── icons
│** │** ├── mozicon128.png
│** │** └── updater.png
│** ├── jsloader
│** │** └── resource
│** ├── libfreebl3.chk
│** ├── libfreebl3.so
│** ├── libmozalloc.so
│** ├── libmozsqlite3.so
│** ├── libnspr4.so
│** ├── libnss3.so
│** ├── libnssckbi.so
│** ├── libnssdbm3.chk
│** ├── libnssdbm3.so
│** ├── libnssutil3.so
│** ├── libplc4.so
│** ├── libplds4.so
│** ├── libsmime3.so
│** ├── libsoftokn3.chk
│** ├── libsoftokn3.so
│** ├── libssl3.so
│** ├── libxpcom.so
│** ├── libxul.so
│** ├── mozilla-xremote-client
│** ├── omni.ja
│** ├── platform.ini
│** ├── plugin-container
│** ├── precomplete
│** ├── removed-files
│** ├── run-mozilla.sh
│** ├── searchplugins
│** │** ├── amazondotcom.xml
│** │** ├── bing.xml
│** │** ├── eBay.xml
│** │** ├── google.xml
│** │** ├── twitter.xml
│** │** ├── wikipedia.xml
│** │** └── yahoo.xml
│** ├── Throbber-small.gif
│** ├── updater
│** ├── updater.ini
│** └── update-settings.ini
├── linux command learning.pdf
└── qBT_dir
this is the tree ...
and the names of files are dec.h and def.h!! but how can name of file matter(if it is typed correctly in each step??

Check the owner of your files. If the owner of your CPP file and .h file is different then may this problem will occur.
After changing the owner if still problem persists then in your CPP file include like this #include "fullpath to def.h"
This should solve your problem.
 
1 members found this post helpful.
Old 07-04-2012, 07:02 AM   #11
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
instead of #include "fullpath to file" use: #include "file.h" and gcc -I <path to file.h> ...
 
1 members found this post helpful.
Old 07-05-2012, 12:33 AM   #12
amitback
LQ Newbie
 
Registered: Jun 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
thanks frnds my issue is solved and now i can run my c++ program on linux very comfortably ...thank u so much for your help!!
 
  


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
A note on tcp/ip programming and header requests eagle-bear Programming 2 01-16-2012 12:18 PM
Linux header files missing and v4l files unable to compile szutshi Linux - Newbie 5 09-13-2011 03:00 PM
using header files: how do you ref and put fumulas in headers files cuthbertmd1 Programming 7 02-15-2011 07:25 AM
How to check missing header files included from another header file adisan82 Linux - Software 1 01-28-2011 04:57 AM
c header files in linux in place of header files in windows? harun_acs Programming 1 03-17-2004 03:24 AM


All times are GMT -5. The time now is 06:41 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration