Joe Pfeiffer <> writes:
> Angel <angel+> writes:
>> On 2012-09-09, Giuseppe Longo <> wrote:
>>> Hello guys,
>>> i've a little problem with gcc.
>>>
>>> I've created two project with eclipse, and the first project is used
>>> to compile the second.
>>>
>>> I try to compile with the command:
>>> gcc -I /prog1/src/ -L /prog1/src -o main main.c
>>>
>>> But, i got this error: Undefined reference
>>
>> You didn't provide nearly enough information for anyone to determine
>> what's going on. You should at the very least have copy-pasted the
>> exact error message which should tell you what's missing.
>>
>> Most likely though, you forgot to tell gcc to use a certain library
>> while linking. For example, if you use the functions of the math
>> library (those defined in math.h), you should include the -lm option in
>> your command.
>
> The other likely bug is you mis-spelled a function, for instance you
> called Sin() instead of sin(), or you defined myfunction() but called
> myfnction().
Yes, but that kind of error can be avoided (or at least detected
more easily) by #include'ing the proper headers for any functions
you call, and by invoking your compiler in a mode that causes it
to warn about calls to undeclared functions.
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"