LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   linking problem with gcc (https://www.linuxquestions.org/questions/programming-9/linking-problem-with-gcc-384649/)

tokernizer 11-19-2005 12:02 PM

linking problem with gcc
 
i have several functions written in different source files all in the same directory. i wrote the prototypes of theses functions in a header file called "filter.h" and included this header file in necessary functions. the main function is in a file called "filter.c". the directory looks like below:
/root/src/
|-- filter.c
|-- filter.h
|-- makefile
|-- shrink.c
...(and other functions)

my makefile is like below:
filter: filter.o
gcc -L/root/src filter.o
filter.o: filter.c filter.h
gcc -c -I/root/src filter.c

when i type "make" in the console, i get these messages:
gcc -c -I/root/exp3 filter.c
gcc -L/root/exp3 filter.o
filter.o(.text+0x25): In function `main':
: undefined reference to `shrink'
collect2: ld returned 1 exit status

"shrink" is the only funcion used in "main". there is no problem in compiling, so i suppose the linker doesn't see my header file "filter.h".where do i make the mistake?

Vookimedlo 11-19-2005 12:56 PM

Try this:

Code:

filter: filter.c shrink.o
        gcc -o filter filter.c shrink.o
shrink.o: shrink.c shrink.h
        gcc -c shrink.c



All times are GMT -5. The time now is 03:21 AM.