Operating System - HP-UX
1751925 Members
5231 Online
108783 Solutions
New Discussion

Re: linking error : "Unsatisfied symbol ..."

 
bluebriz
Occasional Visitor

linking error : "Unsatisfied symbol ..."

Hi

 

I encountered  linking error while compiling my simple code in HP-UX (B.11.23)

 

error : 

$ gcc -g -Wall -I/usr/local/ssl/include/openssl -c my_sha.cpp
$ gcc -o MY_SHA my_sha.o -lstdc++ -L/usr/local/ssl/lib -lcrypto
ld: Unsatisfied symbol "SHA512" in file my_sha.o
1 errors.
collect2: ld returned 1 exit status

 

i checked crypto library by 'nm' command, it seems that the library has SHA512 function.

 

nm : 

$ nm /usr/local/ssl/lib/libcrypto.a | grep SHA512
0000000000000010 T SHA512
0000000000000010 T SHA512_Final
0000000000000000 T SHA512_Init
0000000000000000 T SHA512_Transform
0000000000000000 T SHA512_Update
0000000000000000 R SHA512_version
                 U SHA512_Final
                 U SHA512_Init
                 U SHA512_Update

 

in other system (Linux), this code can be complied successfully.

but I tried in HP-UX, I can't ...

 

Is there any reason I can't know ?

 

I'm hoping for anyone's any advice .. :)

 

 

my code : 

#include <openssl/evp.h>
#include <string.h>
#include <string>
#include "sha.h"

using namespace std;

string base64_encodestring(int nLen, char *pData)
{
        EVP_ENCODE_CTX ectx;
        int outlen = 0, tlen = 0;
        int size = nLen + 34;
        unsigned char* out = (unsigned char*)malloc(size);

        EVP_EncodeInit(&ectx);
        EVP_EncodeUpdate(&ectx, out, &outlen, (const unsigned char *)pData, nLen);
        tlen += outlen;
        EVP_EncodeFinal(&ectx, out+tlen, &outlen);
        tlen += outlen;
        out[tlen] = '\0';
        string str = (char*)out;
        free(out);
        return str;
}

int main(int arc, char **argv)
{
        char strPinORG[16], strPinSSL[256];
        memset(strPinORG, 0x00, sizeof(strPinORG));
        memset(strPinSSL, 0x00, sizeof(strPinSSL));

        strncpy(strPinORG, argv[0], 15);

        //sha-512 (strPinORG --> strPinSSL)
        SHA512((unsigned char *)strPinORG, strlen(strPinORG), (unsigned char *)strPinSSL);

        //encode (strPinSSL --> strPinNo)
        string strPinNo = base64_encodestring(64, strPinSSL);

        //printf("strPinNo=[%s]\n", strPinNo);

        return EXIT_SUCCESS;
}

 

P.S. This thread has been moved from HP-UX>General to  HP-UX > languages. -HP Forum Moderator

3 REPLIES 3
Dennis Handly
Acclaimed Contributor

Re: linking error : "Unsatisfied symbol ..."

$ gcc ... -lstdc++ -L/usr/local/ssl/lib -lcrypto

$ nm /usr/local/ssl/lib/libcrypto.a | grep SHA512

0000000000000010 T SHA512

 

It looks like your system has illegally placed a 64 bit lib in a lib/ directory instead of the standard lib/hpux64/.

You need to get a 32 bit version of that lib and change that -L, or build with 64 bit.

bluebriz
Occasional Visitor

Re: linking error : "Unsatisfied symbol ..."


@Dennis Handly wrote:

... 

It looks like your system has illegally placed a 64 bit lib in a lib/ directory instead of the standard lib/hpux64/.

You need to get a 32 bit version of that lib and change that -L, or build with 64 bit.


hi Dennis.

thanks for reply :)

 

first of all, I want to compile my code with 64 bit.

and I have to use openssl lib for SHA512. 

 

as you said, the lib is not in /usr/lib/hpux64.

the standard lib - libcrypto.a - in /usr/lib/hpux64 is not support SHA512.

 

so I downloaded openssl  from openssl official site, and I compiled and install it.

as a result, it's lib file installed in the path (/usr/local/ssl/lib).

 

so I tried to re-install again (with 64 bit), but the error occured again..

$ gcc -g -Wall -I/usr/local/ssl/include/openssl -c my_sha.cpp
$ gcc -o MY_SHA my_sha.o -lstdc++ -L/usr/local/ssl/lib -lcrypto
ld: Unsatisfied symbol "SHA512" in file my_sha.o
1 errors.
collect2: ld returned 1 exit status

 

and I confirmed library again..

$ nm /usr/local/ssl/lib/libcrypto.a | grep SHA512
0000000000000980 T SHA512
0000000000000200 T SHA512_Final
0000000000000100 T SHA512_Init
00000000000007a0 T SHA512_Transform
0000000000000510 T SHA512_Update
0000000000000000 R SHA512_version
                 U SHA512_Final
                 U SHA512_Init
                 U SHA512_Update

 

give me advice please..

 

Dennis Handly
Acclaimed Contributor

Re: linking error : "Unsatisfied symbol ..."

>I want to compile my code with 64 bit.

 

Since the default is 32 bit, you need to add an option for both compiling and linking, something like: -mlp64

 

>the lib is not in /usr/lib/hpux64.

 

It doesn't have to be in /usr/lib, but it has to be in .../lib/hpux??/.