0

I am trying to create an executable with .o ,.so, .a files.

Here is my build command:-

pkgs/gcc/v4.8.3/bin/gcc -L/usr/X11R6/lib -O2 -DUSE_FLEX -Wall -Wno-char-subscripts -fPIC -DLINUX -DG_DISABLE_CONST_RETURNS -fno-strict-aliasing -o ../build/kl/Release/test/bin/pure.exe -L../build/kl/Release/test/modules ../build/kl/Release/test/maker/constrfunc.TCL.o ../../build/kl/Release/test/maker/pvdbprocs.TCL.o .. ../build/kl/Release/test/maker/maker/memmaker.TCL.o .. ../build/kl/Release/test/maker/modules/libdenbase.a .. ../build/kl/Release/test/maker/guibase.o -litk3.2 -litcl4.0.0 -ltk8.3 -lcdnviptcl8.4 -litclstub4.0.0 -ldenbase -lglib-2.0 -ldenbase -lX11 -ldl -lm -lviputil -lvippli -lcdsCommonMT_sh -lpthread  -L/home/dlb/extlibs/arm/lib 

I have libraries which have definitions of the functions at path "-L/home/dlb/extlibs/arm/lib" . Still it is throwing error below.

Error:

../build/kl/Release/test/maker/guibase.o: In function `decodeAddrList':
tree234.c:(.text+0xc): undefined reference to `ptritclStubsPtr'
tree234.c:(.text+0x20): undefined reference to `ptrlitclStubsPtr'
tree234.c:(.text+0x12c): undefined reference to `ptrlitclStubsPtr'
tree234.c:(.text+0x140): undefined reference to `ptrlitclStubsPtr'

I have the symbol in library which is at path /home/dlb/extlibs/arm/lib :-

Command:-

readelf -s libitcl4.0.0.so | grep ptrlitclStubsPtr

348: 0000000000060f10     8 OBJECT  LOCAL  DEFAULT   24 ptrlitclStubsPtr

Am I missing some thing here?

Note, OP has provided more info in a repost of the same question;
quote from comment by OP:
"Due to some privacy issues...I am renaming the symbols.. It was edited by me... It was typo...I just corrected it...:)"
I.e. the identifiers in the error message and the grep line and the output of the grep line have been manually altered.

13
  • 2
    I think the -L... need to go before the -l... switches for libtcl et al. Commented May 21, 2018 at 9:35
  • it will be better to a write a Makefile ,if your build command is this much big. Commented May 21, 2018 at 9:40
  • @AjayBrahmakshatriya, actuall symbol name is 'ptrlitclStubsPtr' .. I just edited the question.. please check. Commented May 21, 2018 at 9:44
  • @zappy, the command is from build log only. I am not running separately. it is from makefile. Commented May 21, 2018 at 9:45
  • 1
    Then better to post your make file also Commented May 21, 2018 at 9:48

1 Answer 1

1

It looks like the functions you're asking about are local to the file where they were defined. That is, it looks like they were explicitly intended not (and not even allowed) to be called externally.

That is, somewhere within the source for the shared library libitcl4.0.0.so probably appears a declaration like:

static tclStubs *ptrlitclStubsPtr;

That keyword static indicates that the visibility of the resulting symbol ptrlitclStubsPtr is confined to its own source file.

I infer all of this from the fact that your reported readelf output includes the line

348: 0000000000060f10     8 OBJECT  LOCAL  DEFAULT   24 ptrlitclStubsPtr

That flag LOCAL indicates that the symbol is local. If it were global, intended (and able) to be called externally, the flag GLOBAL would appear instead.

Why are variables made private (static) like this, so you can't use them? It's a software engineering thing, "information hiding", intended to reduce the "width" of the interface between you and a library like libitcl4. Symbols that are private are more intimately tied to the implementation decisions within libitcl4, decisions which are not supposed to be visible to, or any concern of, the callers. It's thought that, if callers were to have access to those symbols, callers would also have to know other implementation details, meaning that the author of libitcl4 would then be unable to change those implementation details without breaking (invalidating) the calling code. So to prevent that situation, the choice is usually made to make it impossible for the caller to become dependent in this way.

In this situation you basically have three paths forward:

  1. Remove the static tags from the variable declarations in the sources to libitcl4.0.0.so. (This obviously requires that you have access to the sources to libitcl4.0.0.so, and the ability to rebuild it. It's also probably a very bad idea. As I've explained, those symbols were probably made static for a good reason.)

  2. Add a new function within libitcl4.0.0.so which does whatever you need done, and which, by virtue of its placement within the same source file, does have access to those symbols. (This, too, requires that you have access to and the ability to rebuild ``libitcl4.0.0.so`.)

  3. Find some other way of doing whatever you need done, using the existing public facilities of libitcl4.0.0.so.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks for your reply. Unfortunately , we don't have source for that library.. But,i found one alternate library 'libcdnviptcl8.4' which has this symbols 'GLOBAL ' readelf -s libcdnviptcl8.4.so | grep prttclStubsPtr 636: 00000000000d8068 8 OBJECT GLOBAL DEFAULT 24 ptrtclStubsPtr I have executed the command including that library and still facing the same issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.