0

Encountering error while creating a shared library of AES. The following commands are used :

gcc -Wall Test1.c x64/libSESDAPI.a -fPIC -lssl -lcrypto

gcc -shared -o libfile.so a.out -nostartfiles

And I am getting the following errors:

/usr/bin/ld: error in a.out(.eh_frame); no .eh_frame_hdr table will be created.

/usr/bin/ld: libfile.so: No symbol version section for versioned symbol `AES_cbc_encrypt@@OPENSSL_1.0.0'

/usr/bin/ld: final link failed: Nonrepresentable section on output collect2: error: ld returned 1 exit status

I am new to shared libraries so please help.

Edit: I have edited and added the lcrypto and lssl

Edit2: By adding a -c in the first command, the above errors are now resolved. But now accessing the .so file with python gives a new error

OSError: ./libfile.so: undefined symbol: SDSCListDevs

Please tell why this error is coming.

1 Answers1

1

You should be creating your shared library from an object file, not from an executable program.

You also need to link with the SSL libraries.

Commands to use:

# Compile the source file, generate object file
gcc -Wall Test1.c -c -fPIC

# Link object file with libraries to create the shared object
gcc -shared -fPIC -o libfile.so Test1.o x64/libSESDAPI.a -lssl -lcrypto
Some programmer dude
  • 400,186
  • 35
  • 402
  • 621