4

I'm trying to cross compile my application for the maemo environment (GNU). When compiling the application normally, everything works fine, however when it's compiled through sb2 the following warning comes up:

$ sb2 gcc -D_GNU_SORCE -o app -Wall -g -I.......//don't think this is relevant

 In file included from wifi_collector_menu.c:50:
 wifi_collector_list.c: In function `show_net_apns':
 wifi_collector_list.c:777: warning: implicit declaration of function `getline'

I am completely confused as to why this happens, there are other getlines that do work in the program, i have tried to define the variable _GNU_SOURCE both inside the code and in the compiler command (not at the same time) This is the line of code which causes the warning apparently:

size_t bytesnum = MAX_ESSID;
size_t bytes_read;
char *netname = NULL;
printf("Enter name of selected network:");
bytes_read=getline(&netname,&bytesnum,stdin);//This line

Any help would be appreciated, thanks in advance.

Jasper
  • 75,717
  • 14
  • 151
  • 146
Jaime Borondo
  • 421
  • 1
  • 6
  • 14
  • Also, the application doesn't recognise correctly the value EOF we use in the desktop version to detect when Ctrl+D is pressed. – Jaime Borondo Dec 12 '11 at 21:16

2 Answers2

20

Problem solved, all I had to do was add:

#define _GNU_SOURCE

In each header file, before stdio.h was included, very simple really.

I guess this info is assumed known between programmers as i was unable to find it anywhere online, and had to ask my C programming professor personally, and even then we had some trouble tracing the source.

Thanks anyway.

Jaime Borondo
  • 421
  • 1
  • 6
  • 14
1

Change your compiler line to include the -E option and redirect the output. The compiler will only pre-proccess your file when this option is used. Do this for both versions, with and without sb2. getline() is normally found in stdio.h. By viewing the preprocessed output from both versions, you should be able to see where getline() is being included from.

Jasper
  • 75,717
  • 14
  • 151
  • 146
scanjr
  • 11
  • 1
  • That shows me several "no newline at end of file" (wich were also showing earlier, but these can be handled easily) as well as a new warning: arm-none-linux-gnueabi-gcc: -lm: linker input file unused because linking not done – Jaime Borondo Dec 12 '11 at 22:00