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!! |
#include"filenamae.h"
Is it a typo? Or because of this you are seeing the issue? :) -kd |
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)
|
Quote:
|
Quote:
and I am logged in as root!! is there any problem bcoz i dnt have any imp data in my hdd |
Quote:
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. |
Quote:
├── 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?? |
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.. |
Quote:
how can I check whether they are in same directory or not? you may seem questions very silly but i am complete newbie!! |
Quote:
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. |
instead of #include "fullpath to file" use: #include "file.h" and gcc -I <path to file.h> ...
|
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!!
|
All times are GMT -5. The time now is 10:49 PM. |