undefined reference in g++ compilation

Status
Not open for further replies.

pancho_hideboo

Advanced Member level 5
Joined
Oct 21, 2006
Messages
2,847
Helped
767
Reputation
1,536
Reaction score
733
Trophy points
1,393
Location
Real Homeless
Activity points
17,490
I failed in building g++ program.
Code:
g++ -o hoge hoge.o .... -lm -lncurses -lreadline -lhistory

Code:
hoge.o:hoge.cc:(.text+0x181): undefined reference to `_LINES'
hoge.o:hoge.cc:(.text+0x18f): undefined reference to `_COLS'
hoge.o:hoge.cc:(.text+0x199): undefined reference to `_TABSIZE'
hoge.o:hoge.cc:(.text+0x2418): undefined reference to `_stdscr'
hoge.o:hoge.cc:(.text+0x37e6): undefined reference to `_COLS'
hoge.o:hoge.cc:(.text+0x37ec): undefined reference to `_LINES'
hoge.o:hoge.cc:(.text+0x3805): undefined reference to `_TABSIZE'
hoge.o:hoge.cc:(.text+0x3858): undefined reference to `_ESCDELAY'
hoge.o:hoge.cc:(.text+0x3980): undefined reference to `_stdscr'

Is there any lack for library ?
 

Have you checked if the Makefile file contains the paths to all the necessary includes for your code, or if all the files and directories referred there are really present on respective folders ?
 

Thanks for replying.

Have you checked if the Makefile file contains the paths to all the necessary includes for your code, or if all the files and directories referred there are really present on respective folders ?
I suspect lack of "#include <???.h>" in hoge.cc.
 

the errors are for 'curses' package. either #include <curses.h>

or

the library path for curses.so is not in order.
 

Thanks for replying.

the errors are for 'curses' package. either #include <curses.h>
or
the library path for curses.so is not in order.
Of course, I suspect library specified order in linking.
Code:
-lm -lncurses -lreadline -lhistory
Code:
-lncurses -lreadline -lhistory -lm

However I can not succeed in compilation.
 

did you try including the -I /-L switch if the curses is not in search path?
 

if -I/-L switch has the same error message , then -lncurses should be the last in linking as:

lm- -lreadline -lhistory -lncurses
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…