getline function

Tom Grove freebsd at voidmain.net
Sat Feb 18 07:55:34 PST 2006


Mike Jeays wrote:
> On Fri, 2006-02-17 at 21:54 -0500, Tom Grove wrote:
>   
>> Is there anyone who can compile a program using the getline() function?  
>> Here is a really simple program to recreate the following error:
>>
>> ##Error##
>> /var/tmp//ccvYIi4C.o(.text+0x26): In function `main':
>> : undefined reference to `getline'
>> ##Error##
>>
>> ##Source File##
>> #include <stdio.h>
>>
>> int main() {
>>         char line[10];
>>
>>         getline(&line, 10);
>>         printf("%s", line);
>>
>>         return 0;
>> }
>> ## Source File##
>>
>> -Tom
>> _______________________________________________
>> freebsd-questions at freebsd.org mailing list
>> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
>> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
>>     
>
> I got a bit further by installing the port for getline
> (/usr/ports/devel/libgetline), and changed the code slightly to provide
> a single parameter. (Look at man getline)
>
> #include <stdio.h>
> #include <getline.h>
>
> int main() {
>         char line[10]="test";
>
>         getline(line);
>         printf("%s", line);
>
>         return 0;
> }
>
> chaucer 29 ~/c $ cc -o getline -I/usr/local/include -L/usr/local/lib
> getline.c -lgetline
> chaucer 30 ~/c $ getline
> testnow
> testchaucer 31 ~/c $ 
>
>
>
>   
That works and I had looked into that earlier...it seems like it does a 
lot more than just one function from the man page.  I guess I can use 
that for now but I wonder why getline() is broken in gcc on FreeBSD?

-Tom


More information about the freebsd-questions mailing list