|
Home > Archive > Unix Programming > January 2004 > view the symbol inside the .so or .o file
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
view the symbol inside the .so or .o file
|
|
|
| This question is simple, I think, although I searched google and got
no hints ( I must have chosen the in-appropriate keywords ).
I am looking for a tool that can help me to see the symbols ( function
names ) inside a .so or .o file.
My real problem is when linking with command like
# g++ -o myapp.o file1.o file2.o file3.o -lmylib -L. -R.
with -lmylib is for a libmylib.so containing some common functions
cmf1(), cmf2() ... to which all file1.cpp, file2.cpp and file3.cpp
call.
I get the error :
Undefined first referenced
symbol in file
cmf1 file2.o
cmf2 file2.o
What I don't understand here is why it applies to *only* f2. I define
the
#ifdef __cplusplus
extern "C" {
#endif
and
#ifdef __cplusplus
}
for those common functions cmf1() and cmf2().
Thanks for your help,
DT
[ It did work at around 2AM. Maybe I need some sleep :-) ]
| |
| Jerry Feldman 2004-01-23, 5:21 pm |
| On 28 Dec 2003 07:25:16 -0800
dt1649651@yahoo.com (vp) wrote:
quote:
> This question is simple, I think, although I searched google and got
> no hints ( I must have chosen the in-appropriate keywords ).
>
> I am looking for a tool that can help me to see the symbols ( function
> names ) inside a .so or .o file.
nm(3) is the command you need. There are many options, such as whether
or not to demangle a symbol. (C++ symbols are mangled).
--
Jerry Feldman <gaf-nospam-at-blu.org>
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
| |
| Jens.Toerring@physik.fu-berlin.de 2004-01-23, 5:21 pm |
| vp <dt1649651@yahoo.com> wrote:quote:
> This question is simple, I think, although I searched google and got
> no hints ( I must have chosen the in-appropriate keywords ).
quote:
> I am looking for a tool that can help me to see the symbols ( function
> names ) inside a .so or .o file.
quote:
> My real problem is when linking with command like
quote:
> # g++ -o myapp.o file1.o file2.o file3.o -lmylib -L. -R.
quote:
> with -lmylib is for a libmylib.so containing some common functions
> cmf1(), cmf2() ... to which all file1.cpp, file2.cpp and file3.cpp
> call.
Someone else already told you about nm(1) which lets you see the
symbols in an .o or .so file. But there might already be something
broken with your command line: you may need the "-L." *before* the
"-lmylib" in case libmylib.so is in the current directory.
Regards, Jens
--
\ Jens Thoms Toerring ___ Jens.Toerring@physik.fu-berlin.de
\__________________________ http://www.physik.fu-berlin.de/~toerring
| |
|
| Thanks, Jerry and Jens, for your help.
Yes, it is the "nm" that i was looking for.
I found the problem , although it is a little weird : I must have
mistyped some commands and there are some extra empty .c files with
the same name with the .cpp files. After deleting these extra .c files
and running make clean / make all, those errors disappeared.
I found these .c file names when using the nm.
Thanks again.
DT
PS: it's fun to mention that I could not find that error until
deciding to take a break by watching "The Italian job", and I do like
Lyle, the Napster computer guy :-)
|
|
|
|
|