compilation error

A

aki

Hi frnds ,

i have written a satck program stack.cpp,
When i compiling the program using command
g++ stack.cpp -o stack

i am getting output as :

Undefined first referenced
symbol in file
stdscr /var/tmp//ccRwixiK.o
wgetch /var/tmp//ccRwixiK.o
ld: fatal: Symbol referencing errors. No output written to stack


i donot know how to debug my program .. and how to go ahead in
debugging .

Can somebody help me..

best regards
aki
 
I

Ian Collins

aki said:
Hi frnds ,

i have written a satck program stack.cpp,
When i compiling the program using command
g++ stack.cpp -o stack

i am getting output as :

Undefined first referenced
symbol in file
stdscr /var/tmp//ccRwixiK.o
wgetch /var/tmp//ccRwixiK.o
ld: fatal: Symbol referencing errors. No output written to stack
You have omitted the library that defines those (non-standard)
functions. The man page for one or other should enlighten you.
 
A

aki

thanks for answering my query .
Actually i was using
getch() in the program .
Insted of it , i now used cin to get input from keyboard .

tat seems to be ok

But i am not getting wat was strange before.
i used header file curses.h for getch(); function.
i am working under solaris .

Best regards
Aki
 
I

Ian Collins

[please keen enough context for your reply to make sense]
thanks for answering my query .
Actually i was using
getch() in the program .
Insted of it , i now used cin to get input from keyboard .

tat seems to be ok

But i am not getting wat was strange before.
i used header file curses.h for getch(); function.
i am working under solaris .
Do as I suggested and read the man page. Note the compilation line.

You should always start with man pages or other documentation when you
have a problem like the one you described.
 
E

Eugene Vernikovskiy

aki said:
thanks for answering my query .
Actually i was using
getch() in the program .
Insted of it , i now used cin to get input from keyboard .

tat seems to be ok

But i am not getting wat was strange before.
i used header file curses.h for getch(); function.
i am working under solaris .

Best regards
Aki

C/C++ header files keep declarations of the functions (the name of the
function, its return type and the list of parameters). The compiler
knows how to build your code based on these declarations. The compiler
builds not the application but the object file though. The object file
is used later by the linker to build the application. The linker has to
link your code to the actual functions (function definitions, body of
the functions) and this information is not located in the header files.
The functions are located in C/C++ libraries so it is necessary to
provide a list of the libraries you want to use in your application to
the linker.

Please notice, that the header files and the library files must match
each other. It is possible (in C) to have a function in the header with
one set of the parameters and the functions in the library with the same
name but different set of parameters (in case the header file is from a
different library or has been modified by hands after the library was
compiled).

Other languages (like Java) solve the problem of the
declaration/definition mismatch by putting the declarations in the same
file with the definitions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top