1753893 Members
7415 Online
108809 Solutions
New Discussion юеВ

_mcount unresolved

 
bhanu405
Occasional Advisor

_mcount unresolved

Hi,

We are building a shared library on HP 11.11 with aCC compiler. When we try use the .sl in our binary we get the below error message:

/usr/lib/dld.sl: Unresolved symbol: _mcount (code) from ../../XYX.sl
/usr/lib/dld.sl: Call to __sigenable() failed
/usr/lib/dld.sl: Not owner

This is the command we give to build the .sl:
aCC -b -mt -Wl,+s -Wl,+b,/usr/lib:. -lCsup -lCsup_v2 -lstd_v2 -lcaopenssl_crypto_stub -lcaopenssl_ssl_stub -lcapki_stub -lcurl -lpcre -llgr -lmesgparsing -lrusl -lhash -lifp -lutls -lbreg -lloc -ldlib -lireccrypt -lpcreposix -lGMSG -lGDBG -lENCK -lGLOG -lEncRpc -lmisc -lhash -lSIGN -lc

Please share your observations.

Thanks in advance
Bhanu
11 REPLIES 11
Dennis Handly
Acclaimed Contributor

Re: _mcount unresolved

If you compile your shlib with -G, you must link your application with -G.

>aCC -b -mt -Wl,+b,/usr/lib:. -lCsup -lCsup_v2 -lstd_v2 -lc

Linking shlibs with -mt is now ignored.
You shouldn't link your shlib with -lc, this should be on the executable.
You can't link with both these shlibs: -lCsup -lCsup_v2
Remove the first.
bhanu405
Occasional Advisor

Re: _mcount unresolved

Hi Dennis,

Thanks for the quick response. I made the changes as you suggested but the problem still exists. The other thing is that we are not linking the shlib from our application but we are using dlopen to access its functions.

This is how I compiled the shlib:

aCC -G -b -Wl,+s -Wl,+b,/usr/lib:. -lCsup_v2 -lstd_v2 -lcaopenssl_crypto_stub -lcaopenssl_ssl_stub -lcapki_stub -lcurl -lpcre -llgr -lmesgparsing -lrusl -lhash -lifp -lutls -lbreg -lloc -ldlib -lcawinHP -lireccrypt -lpcre -lpcreposix -lGMSG -lGDBG -lENCK -lGLOG -lEncRpc -lmisc -lhash -lSIGN

one more observation I made is that by using -lgprof32 option I am not getting the above errors but still the shlib fails to get loaded by the application.

Thanks
Bhanu
Dennis Handly
Acclaimed Contributor

Re: _mcount unresolved

>I made the changes as you suggested but the problem still exists.

(You didn't remove -G from the compile line.)

>This is how I compiled the shlib: aCC -G -b

Any reason you are using -G?

>-lCsup_v2 -lstd_v2

These are in the wrong order and they need to be last. See:
http://docs.hp.com/en/14672/Help/distributing.htm#linking

>one more observation I made is that by using -lgprof32 option I am not getting the above errors but still the shlib fails to get loaded by the application.

What's the error?
bhanu405
Occasional Advisor

Re: _mcount unresolved

Hi Dennis,

I have recompiled the shlib with the below options:

aCC -b -Wl,+s -Wl,+b,/usr/lib:. -lstd_v2 -lCsup_v2 -L"/usr/local/lib/" -o release.hpux/XYZ.sl -lcaopenssl_crypto_stub -lcaopenssl_ssl_stub -lcapki_stub -lcurl -lpcre -llgr -lmesgparsing -lrusl -lhash -lifp -lutls -lbreg -lloc -ldlib -lireccrypt -lpcreposix -lGMSG -lGDBG -lENCK -lGLOG -lEncRpc -lmisc -lhash -lSIGN

and tried to dlopen with the below code :

#include
#include
#include

int main(int argc, char **argv) {
void *handle;
double (*cosine)(double);
char *error;

handle = dlopen ("./XYZ.sl", RTLD_LAZY);
if (!handle) {
fputs (dlerror(), stderr);
exit(1);
}

/*func = dlsym(handle, "cos");
if ((error = dlerror()) != NULL) {
fputs(error, stderr);
exit(1);
}

printf ("%f\n", (*cosine)(2.0));
*/
dlclose(handle);
}


and I get the below error:

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


Please share your observations:
Ths os and comapiler versions are:HP-UX bso-sdhp B.11.23 U 9000/800 and aCC: HP ANSI C++ B3910B A.03.90

Thanks
Bhanu
Dennis Handly
Acclaimed Contributor

Re: _mcount unresolved

>-lstd_v2 -lCsup_v2

As I mentioned, these must be the very last aC++ shlibs on the link line.

>dld.sl: Unresolved symbol: _mcount (code) from ./BABiSponsor11UX.sl

You need to rebuild this shlib without -G. Or possibly add -lgprof to it.
bhanu405
Occasional Advisor

Re: _mcount unresolved

Yes, in my last post i rebuilt without the -G option only.



Dennis Handly
Acclaimed Contributor

Re: _mcount unresolved

>I rebuilt without the -G option only.

Then what is your current problem/error?
bhanu405
Occasional Advisor

Re: _mcount unresolved

Hi Dennis,

I have tried it once more today , but no luck. I tried compiling the shlib with the below options :

aCC -b -Wl,+s -Wl,+b,/usr/lib:. -L"/usr/local/lib/" -o release.hpux/XYZ.sl -lcaopenssl_crypto_stub -lcaopenssl_ssl_stub -lcapki_stub -lcurl -lpcre -llgr -lmesgparsing -lrusl -lhash -lifp -lutls -lbreg -lloc -ldlib -lireccrypt -lpcreposix -lGMSG -lGDBG -lENCK -lGLOG -lEncRpc -lmisc -lhash -lSIGN -lstd_v2 -lCsup_v2 -lgprof32 -lpthread

Changes i made:
1) added -lgprof32 and removed -G
2) added -lpthread as there was a "Can't dlopen() a library containing Thread Local Storage: /usr/lib/libpthread.1" error
3) Removed -lCsup since -lCsup_v2 is present in the link line and placed "-lstd_v2 -lCsup_v2" at the end of the link line.

Every time i try to load the shlib with the application, I get one consistent error i.e

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


Please suggest your changes...

Thanks
Bhanu
Dennis Handly
Acclaimed Contributor

Re: _mcount unresolved

>aCC -b -o XYZ.sl -lcaopenssl_crypto_stub -lcaopenssl_ssl_stub -lcapki_stub -lcurl -lpcre -llgr -lmesgparsing -lrusl -lhash -lifp -lutls -lbreg -lloc -ldlib -lireccrypt -lpcreposix -lGMSG -lGDBG -lENCK -lGLOG -lEncRpc -lmisc -lhash -lSIGN -lstd_v2 -lCsup_v2 -lgprof32 -lpthread

You shouldn't add -lpthread to shlibs.
(Are you sure it isn't just -lgprof?)

>1) added -lgprof32 and removed -G

Have you recompiled any archive or shlib that you previously compiled with -G?
You can find these with:
-Wl,-y_mcount

>2) added -lpthread as there was a "Can't dlopen() a library containing Thread Local Storage: /usr/lib/libpthread.1" error

You need to add -lpthread to your executable, not your shlib. In fact, why are you adding it at all?

>I get one consistent error i.e
>Unresolved symbol: _mcount (code) from ./XYZ.sl

You need to hunt down that object and recompile it.