FUNC LOCL entries in nm

M

Merrill Lane

Hi,

I am attempting to link an object file and a shared library into an executable.
My object file makes calls to two functions in the shared library (MY_FUNC1
and MY_FUNC2).

I am seeing the following error:

==> cc -o MY_EXECUTABLE MY_OBJECTFILE -L. -R. -lMY_SHARED_LIBRARY
Undefined first referenced
symbol in file
MY_FUNC1 MY_OBJECTFILE
ld: fatal: Symbol referencing errors. No output written to
MY_EXECUTABLE

When I do an "nm" on the shared library, grepping for the functions I use,
I get:


[...] | ...| ...|FUNC |LOCL |2 |10 |MY_FUNC1
[...] | ...| ...|FUNC |GLOB |0 |10 |MY_FUNC2

So it makes sense that I got the linker error because MY_FUNC1 is
LOCL. However, both functions have prototypes in the same public header file,
with the same storage modifiers (extern). Neither of the functions is static.
So, my question is, why is MY_FUNC1 made into a LOCL function, unusable by
by my executable (while MY_FUNC2 is GLOB and usable by my executable).

Any thoughts would be appreciated.

Thanks,
Merrill
 
A

Artie Gold

Merrill said:
Hi,

I am attempting to link an object file and a shared library into an executable.
My object file makes calls to two functions in the shared library (MY_FUNC1
and MY_FUNC2).

I am seeing the following error:

==> cc -o MY_EXECUTABLE MY_OBJECTFILE -L. -R. -lMY_SHARED_LIBRARY
Undefined first referenced
symbol in file
MY_FUNC1 MY_OBJECTFILE
ld: fatal: Symbol referencing errors. No output written to
MY_EXECUTABLE

When I do an "nm" on the shared library, grepping for the functions I use,
I get:


[...] | ...| ...|FUNC |LOCL |2 |10 |MY_FUNC1
[...] | ...| ...|FUNC |GLOB |0 |10 |MY_FUNC2

So it makes sense that I got the linker error because MY_FUNC1 is
LOCL. However, both functions have prototypes in the same public header file,
with the same storage modifiers (extern). Neither of the functions is static.
So, my question is, why is MY_FUNC1 made into a LOCL function, unusable by
by my executable (while MY_FUNC2 is GLOB and usable by my executable).

Any thoughts would be appreciated.

Your question is off topic for as it has to do with a
particular compiler/linker as opposed to the language itself. The C
standard is silent about how libraries work.

This question would be appropriate in a compiler- or platform-specific
forum.

<OT>
My SWAG is that MY_FUNC1 has been made local through the use of a linker
script -- and that the header is somehow out of sync with the actual
library. Short of rebuilding the library (or somehow massaging it)
there's nothing you can do.
</OT>

HTH,
--ag
 
M

Mark McIntyre

Hi,

I am attempting to link an object file and a shared library into an executable.
Any thoughts would be appreciated.

You are asking about how to link modules. Thats nothing to do with C,
but to do with your implementation. You need to ask in a more
appropriate group,. perhaps one specialising in whatever compiler you
use.
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top