Search This Blog

Wednesday, May 19, 2010

undefined reference to `_acs_map', `_COLS', and `_LINES'

gcc -O2 -Wall -o nibbles main.o misc.o screen.o -lcurses
screen.o:screen.c:(.text+0xbb): undefined reference to `_acs_map'
screen.o:screen.c:(.text+0x193): undefined reference to `_COLS'
screen.o:screen.c:(.text+0x19d): undefined reference to `_LINES'
screen.o:screen.c:(.text+0x330): undefined reference to `_acs_map'
screen.o:screen.c:(.text+0x362): undefined reference to `_acs_map'
screen.o:screen.c:(.text+0x394): undefined reference to `_acs_map'
screen.o:screen.c:(.text+0x3ec): undefined reference to `_acs_map'
screen.o:screen.c:(.text+0x41a): undefined reference to `_acs_map'
screen.o:screen.c:(.text+0x452): more undefined references to `_acs_map' follow
collect2: ld returned 1 exit status
make: *** [nibbles] Error 1

While compiling 'nibbles' in Cygwin with gcc 4.3.4, I met above errors. These errors happens because of curses. It means that its library is different from the header file curses.h.

There are two libraries of curses. One is libcurses.a for static library, and the other is libncurses.dll.a for shared one. In this case, gcc is looking for libncurses.dll.a, since I didn't specify any option like '-static'. Even more, my cygwin doesn't have libgcc_s, so I can't use the option '-static'.

Thus I need to specify the library more explicitly here like following:
gcc -O2 -Wall -o nibbles main.o misc.o screen.o /usr/lib/libncurses.a

For more information:

No comments:

Post a Comment

Blog Archive