linker problem? (307 Views)
Reply
Occasional Contributor
Moiz Khambaty
Posts: 9
Registered: ‎09-01-2004
Message 1 of 6 (307 Views)

linker problem?

I have created a simple Hello World program given below :

#include
void hello()
{
rintf("Hello World");
}

Here instead of printf I have purposfully put an error namely "rintf"

Now I compiled this code using the comand
/opt/ansic/bin/cc -c +Z -o temp.o temp.c

After compilation I created a library libhello.sl containing the object file created above using the command

/opt/ansic/bin/cc -b temp.o -o libhello.sl

Now the linker is supposed to complain saying "unresolved symbol" for "rintf" but it does not do so. When i use this sl with a sample program still it does not complain about the symbol rintf while compilation. But when I run the sample application, it gives:
/usr/lib/dld.sl: Unresolved symbol rintf (code) from ./libhello.sl
ABORT instruction (core dumped)

Thankyou
Moiz Khambaty
Advisor
Saravanan_6
Posts: 25
Registered: ‎06-05-2003
Message 2 of 6 (307 Views)

Re: linker problem?

U misspelled the printf as rintf. That is the cause for unsatisfied symbol.
Honored Contributor
Muthukumar_5
Posts: 4,030
Registered: ‎06-09-2004
Message 3 of 6 (307 Views)

Re: linker problem?

hai Moiz,

After doing compilation as cc -c <..> we must have to do link to execute the particular object file. So It is not in the linked format.

During the shared library creation it is creating the shared library file using the non-linked temp.o file

So during the application usage on the sl only it is getting linked and getting compiled as,

/usr/lib/dld.sl: Unresolved symbol rintf (code) from ./libhello.sl
ABORT instruction (core dumped)

You can try as,

/opt/ansic/bin/cc temp.c -o temp.o
Some warning will be there from compiler ( -c will supress them and execution file a.out)

If you do it successfully without error then use cc -b temp.o -o libhello.sl


You will get more problem's for your try as

#include
void hello()
{
rintf("Hello World");
}

as
1> no main..
2> return type etc

Regards
Muthu
Easy to suggest when don't know about the problem!
Advisor
Saravanan_6
Posts: 25
Registered: ‎06-05-2003
Message 4 of 6 (307 Views)

Re: linker problem?

Oh sorry I failed to notice

"Here instead of printf I have purposfully put an error namely "rintf" "
Esteemed Contributor
ranganath ramachandra
Posts: 375
Registered: ‎05-16-2003
Message 5 of 6 (307 Views)

Re: linker problem?

the linker does not report unsats from shared libraries by default. it will definitely not error out. if you want warnings, you can get them with the +vshlibunsats linker option.
Esteemed Contributor
ranganath ramachandra
Posts: 375
Registered: ‎05-16-2003
Message 6 of 6 (307 Views)

Re: linker problem?

+vshlibunsats will give you warnings only when linking the shared library.

+vallunsats when linking an executable will list unsats in the shared libraries in the link line.

now by unsats i mean symbols not resolved but required to be resolved, as far as the linker can find out from the direct calls made in the modules being linked.

when building an executable, the linker expects all symbols to be resolved (unless you say +allowunsats). here the requirement for resolving all referenced symbols is driven/ensured by the compiler specifying 'main' as an unsat in the link line (add -v to compile line to see that). so an unresolved symbol is an error in that case.

when building a shared library, the linker actually allows for unsats. so an unresolved symbol will never be an error, it will be a warning at best.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.