| | |
compile header file
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jan 2005
Posts: 24
Reputation:
Solved Threads: 0
STILL trying to figure out how to link files in C++ in a UNIX environment!! i just don't get it. how do i make .o files? what are they for? how do you "link" them with other stuff and "run" them. all i am capable of is g++ somepgm.C
and then a.out
sorrry .... frustrated. prof and TA just ASSUME that i know this ... and i don't.
i have a template class Arrray.h. i need to make a Test.C class that will have main() and make some Array<T> objects and test them. can ANYONE tell me the commands to do this?
thanks
crq
and then a.out
sorrry .... frustrated. prof and TA just ASSUME that i know this ... and i don't.
i have a template class Arrray.h. i need to make a Test.C class that will have main() and make some Array<T> objects and test them. can ANYONE tell me the commands to do this?
thanks
crq
•
•
Join Date: Mar 2004
Posts: 1,620
Reputation:
Solved Threads: 51
Hello,
In my day, we made something called a "makefile" in order to bind it all together. Do a search on makefiles.... I have not built one in quite some time.
I also believe that when the compiler makes the first pass, and sees the .h file referenced, it simply adds that file's text to the main program. I don't think it makes it into a .o and then links them things together. I thought that the compiler command simply hauled the text into a compiler, and then let the dogs loose.
Do not quote me; it has been some time since school.
Christian
In my day, we made something called a "makefile" in order to bind it all together. Do a search on makefiles.... I have not built one in quite some time.
I also believe that when the compiler makes the first pass, and sees the .h file referenced, it simply adds that file's text to the main program. I don't think it makes it into a .o and then links them things together. I thought that the compiler command simply hauled the text into a compiler, and then let the dogs loose.
Do not quote me; it has been some time since school.
Christian
•
•
Join Date: Jan 2005
Posts: 24
Reputation:
Solved Threads: 0
yes. that makes sense to me. yet, my prof wants us to use one of his already compiled files (a .o file) that was made from a .h file. so that's why i was wondering if I needed to do the same.
thanks
crq
thanks
crq
•
•
•
•
Originally Posted by jwenting
headerfiles are not compiled, clear and simple.
.o files are compiled compilation units which have not yet been linked, header files are not compilation units.
•
•
Join Date: Dec 2004
Posts: 60
Reputation:
Solved Threads: 1
•
•
•
•
Originally Posted by jwenting
headerfiles are not compiled, clear and simple.
.o files are compiled compilation units which have not yet been linked, header files are not compilation units.
C++ Syntax (Toggle Plain Text)
// header file #ifndef NUMBERS.H #define NUMBERS.H // Some typical header file stuff #endif
My question was what are the first two lines about. I was told that their purpose was to avoid mutiple compilations. But header files are not compiled!
I should be asking the person who posted the answer to my question, but I don't remeber who that was or what thread it was on. Perhaps you can answer it.
By the way, the header files that come with my compiler, bcc32, have a lot of these "#ifndefine" statements.
•
•
•
•
Originally Posted by murschech
My question was what are the first two lines about. I was told that their purpose was to avoid mutiple compilations.
Last edited by Dave Sinkula; Jan 28th, 2005 at 4:08 pm. Reason: Found and added link.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
•
•
Join Date: Sep 2004
Posts: 10
Reputation:
Solved Threads: 0
Header files aren't compiled but when the compiler sees
#include "filehere.h" ,
it looks for the file for that name in the directories specified. Then it looks through the header during runtime for what you need your code. So #ifndef is a if not defined then #define the file so the compiler knows its right. At least thats how i understand it.
#include "filehere.h" ,
it looks for the file for that name in the directories specified. Then it looks through the header during runtime for what you need your code. So #ifndef is a if not defined then #define the file so the compiler knows its right. At least thats how i understand it.
•
•
Join Date: Dec 2004
Posts: 60
Reputation:
Solved Threads: 1
•
•
•
•
Originally Posted by Dave Sinkula
Perhaps you remember it wrong -- was it to "prevent multiple inclusion"?
While I'm taking advantage of your knowledge, could yu tell me what a "pragma" is?
•
•
•
•
Originally Posted by murschech
Yes, I can see how preventing multiple inclusions would work. (I do think the previous respondant said "multiple compilations", but that's not important) Thank you.
•
•
•
•
Originally Posted by Dave Sinkula
It prevents multiple inclusion of the header.
•
•
•
•
Originally Posted by murschech
While I'm taking advantage of your knowledge, could yu tell me what a "pragma" is?
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Similar Threads
- How do i make a c++ file from a header file thats linked list with a sort function (C++)
- About Header File (C++)
- compile of header, .cpp and program on command line (C++)
- returning a value from a header file (C++)
- graphices header file (C)
- How to write a header file (C++)
Other Threads in the C++ Forum
- Previous Thread: Max and Min values from a group of numbers
- Next Thread: Access Violation (Segmentation Fault) + atol
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock wordfrequency wxwidgets






