| | |
gcc header files and math libary
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Mar 2007
Posts: 50
Reputation:
Solved Threads: 2
I am a new to linux and the gcc system I was just wondering if someone could answer a couple of questions about the including hearder files like the math.h file.
I was making a simple program and using some math trig functions. I keep getting the error cosf undefined text or some thing like that so I got to looking around online and found out it was a linker error. So I typed in the command
Gcc –o test test.c –lm
My question is do I have to add all the include files to the command line?
If not how do I know witch ones I do have to add to the line?
How do you add more then one-header file to the linker?
Does anyone know of a good online resource that would walk me through using the gcc complier.
I was making a simple program and using some math trig functions. I keep getting the error cosf undefined text or some thing like that so I got to looking around online and found out it was a linker error. So I typed in the command
Gcc –o test test.c –lm
My question is do I have to add all the include files to the command line?
If not how do I know witch ones I do have to add to the line?
How do you add more then one-header file to the linker?
Does anyone know of a good online resource that would walk me through using the gcc complier.
>My question is do I have to add all the include files to the command line?
You don't add headers (include files) on the command line. They're strictly for the compiler so that it has declarations for the names that will be linked in later. What you're doing is telling the linker to link with a specific library; in this case that library is the math library. For the most part the standard libraries are linked automagically, with the math library being an exception.
>Does anyone know of a good online resource that
>would walk me through using the gcc complier.
http://gcc.gnu.org/onlinedocs/
You don't add headers (include files) on the command line. They're strictly for the compiler so that it has declarations for the names that will be linked in later. What you're doing is telling the linker to link with a specific library; in this case that library is the math library. For the most part the standard libraries are linked automagically, with the math library being an exception.
>Does anyone know of a good online resource that
>would walk me through using the gcc complier.
http://gcc.gnu.org/onlinedocs/
I'm here to prove you wrong.
•
•
Join Date: Dec 2007
Posts: 11
Reputation:
Solved Threads: 1
Hi,
I happen to bump around wiht this problem too.
I have a .c file and multiple header files.
After executing the -lm flag, I managed to get the executable file. However, when I tried to ./a.out, the compiler just hangs there without any response.
The motivation for me to execute ./a.out is I would like the gcc to generate gcda file for me from gcov.
Please help. Thanks.
-Jason
I happen to bump around wiht this problem too.
I have a .c file and multiple header files.
After executing the -lm flag, I managed to get the executable file. However, when I tried to ./a.out, the compiler just hangs there without any response.
The motivation for me to execute ./a.out is I would like the gcc to generate gcda file for me from gcov.
Please help. Thanks.
-Jason
![]() |
Other Threads in the C++ Forum
- Previous Thread: Help me with classes
- Next Thread: having trouble picking a return type
| Thread Tools | Search this Thread |
api array based binary bitmap 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 java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






