Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-19-2005, 12:02 PM   #1
LQ Newbie
Registered: Nov 2005
Distribution: Ubuntu 5.10
Posts: 6

Rep: Reputation: 0
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:
|-- 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?
Old 11-19-2005, 12:56 PM   #2
Registered: Jul 2004
Location: Czech Republic - Roudnice nad Labem
Distribution: Debian
Posts: 253

Rep: Reputation: 34
Try this:

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

Last edited by Vookimedlo; 11-19-2005 at 12:58 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about GCC linking procedures... vinculum Programming 3 09-26-2005 08:20 AM
gcc linking: undefined reference to just about everything shabbychef Programming 7 09-09-2005 08:42 PM
Problem with linking libraries using gcc shortyzms Linux - Software 1 03-29-2004 08:13 PM
gcc linking error. ugenn Linux - Software 0 01-22-2003 11:18 PM
Linking without gcc, but with ld gluon Programming 3 05-29-2002 05:11 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:45 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration