LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   gcc won't recognise local header files (https://www.linuxquestions.org/questions/linux-software-2/gcc-wont-recognise-local-header-files-91383/)

surio 09-10-2003 05:02 PM

gcc won't recognise local header files
 
Hello everybody,

I am using a dedicated SuSE Linux 8.0 Pentium IV box for some development work on 'C' language. This is my first brush with the gcc(v2.95.1) compiler.

Let me explain my approach to the solution.
I have a mainProg.c which contains most of the variables and the main() function. Another file, llist.c contains one function that is called from mainProg.c for manipulating the data structures in the main program. There is an llist.h that contains the function prototye of llist.c.

When I compile mainProg.c, I have no problems, except for some warnings. However, if I decide to build an executable from these set of files, I get the following errors:

Command:
---------
gcc -lm -o mainProg mainProg.o

Note:- I added -lm after gcc failed to recognise sin, cos and atan functions, *in spite of* my including <math.h>! Can anyone enlighten me on this, please?

P.S: I also tried including "-include llist.h" after -lm

Output:
-------
% make
gcc -lm -include llist.h -o mainProg mainProg.o
mainProg.o: In function `plan_path':
mainProg.o(.text+0xe8): undefined reference to `append_to_list'
mainProg.o(.text+0x194): undefined reference to `append_to_list'
collect2: ld returned 1 exit status
make: *** [mainProg] Error 1
%

Please note that append_to_list is the function included in the file llist.c and prototyped in llist.h. mainProg.c includes the "llist.h" header file in it.

I am currently trying to read the gcc manual. The manual has extensive information in it for all its options(C,C++, Fortran, etc.). It is all very confusing to start at the deep end.

Could anyone please tell me what is happening here, and throw some light on the problem.

I have tried to give as much information as I can, but I am sorry if the post looks long-winded.

Thanks very much for your patience. Any help is much appreciated.

Suresh.


All times are GMT -5. The time now is 12:29 AM.