<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Error in linking a program that includes getline function in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-linking-a-program-that-includes-getline-function/m-p/3680935#M798716</link>
    <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I am trying to compile this test program on my HP machine:-&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt;    FILE * fp;&lt;BR /&gt;    char * line = NULL;&lt;BR /&gt;    size_t len = 0;&lt;BR /&gt;    ssize_t read;&lt;BR /&gt;    fp = fopen("/etc/motd", "r");&lt;BR /&gt;    if (fp == NULL)&lt;BR /&gt;        exit(2);&lt;BR /&gt;    while ((read = getline(&amp;amp;line, &amp;amp;len, fp)) != -1) {&lt;BR /&gt;        printf("Retrieved line of length %zu :\n", read);&lt;BR /&gt;        printf("%s", line);&lt;BR /&gt;    }&lt;BR /&gt;    if (line)&lt;BR /&gt;        free(line);&lt;BR /&gt;    return 1;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This is reporting the following errors on compilation/linking:-&lt;BR /&gt;/usr/ccs/bin/ld: Unsatisfied symbols:&lt;BR /&gt;   getline (first referenced in h.o) (code)&lt;BR /&gt;&lt;BR /&gt;Can anybody suggest something?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Anunay&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;</description>
    <pubDate>Tue, 29 Nov 2005 11:37:10 GMT</pubDate>
    <dc:creator>guptaanunay</dc:creator>
    <dc:date>2005-11-29T11:37:10Z</dc:date>
    <item>
      <title>Error in linking a program that includes getline function</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-linking-a-program-that-includes-getline-function/m-p/3680935#M798716</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I am trying to compile this test program on my HP machine:-&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt;    FILE * fp;&lt;BR /&gt;    char * line = NULL;&lt;BR /&gt;    size_t len = 0;&lt;BR /&gt;    ssize_t read;&lt;BR /&gt;    fp = fopen("/etc/motd", "r");&lt;BR /&gt;    if (fp == NULL)&lt;BR /&gt;        exit(2);&lt;BR /&gt;    while ((read = getline(&amp;amp;line, &amp;amp;len, fp)) != -1) {&lt;BR /&gt;        printf("Retrieved line of length %zu :\n", read);&lt;BR /&gt;        printf("%s", line);&lt;BR /&gt;    }&lt;BR /&gt;    if (line)&lt;BR /&gt;        free(line);&lt;BR /&gt;    return 1;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;This is reporting the following errors on compilation/linking:-&lt;BR /&gt;/usr/ccs/bin/ld: Unsatisfied symbols:&lt;BR /&gt;   getline (first referenced in h.o) (code)&lt;BR /&gt;&lt;BR /&gt;Can anybody suggest something?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Anunay&lt;/STDLIB.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Tue, 29 Nov 2005 11:37:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-linking-a-program-that-includes-getline-function/m-p/3680935#M798716</guid>
      <dc:creator>guptaanunay</dc:creator>
      <dc:date>2005-11-29T11:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: Error in linking a program that includes getline function</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-linking-a-program-that-includes-getline-function/m-p/3680936#M798717</link>
      <description>HP-UX doesn't have getline() although the could get it as a Gnu library function. You probably are porting from Linux; your better choice would be fgets() which is a standard function.&lt;BR /&gt;&lt;BR /&gt;fgets() does not automatically allocate a buffer:&lt;BR /&gt;&lt;BR /&gt;#define BSIZE 1024&lt;BR /&gt;&lt;BR /&gt;char line[BSIZE],*p = NULL;&lt;BR /&gt;&lt;BR /&gt;p = fgets(line,sizeof(line),fp);&lt;BR /&gt;while (p != NULL)&lt;BR /&gt;  {&lt;BR /&gt;    (void) printf("%s",line);&lt;BR /&gt;    p = fgets(line,sizeof(line),fp);&lt;BR /&gt;  }&lt;BR /&gt;(void) fclose(fp);</description>
      <pubDate>Tue, 29 Nov 2005 11:51:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-linking-a-program-that-includes-getline-function/m-p/3680936#M798717</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-11-29T11:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: Error in linking a program that includes getline function</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/error-in-linking-a-program-that-includes-getline-function/m-p/3680937#M798718</link>
      <description>Thanks Clay, &lt;BR /&gt;&lt;BR /&gt;Your solution solved my problem perfectly.&lt;BR /&gt;Anunay</description>
      <pubDate>Wed, 30 Nov 2005 01:23:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/error-in-linking-a-program-that-includes-getline-function/m-p/3680937#M798718</guid>
      <dc:creator>guptaanunay</dc:creator>
      <dc:date>2005-11-30T01:23:26Z</dc:date>
    </item>
  </channel>
</rss>

