0

while compiling my cpp program for pop os using 7-zip lzma sdk i encounter the following errors

/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000001410
/usr/bin/ld: Aes.o: in function 'AesGenTables':
/home/hitesh/lzma2201/C/Aes.c:130: undefined reference to 'AesCbc_Decode_HW'
/usr/bin/ld: /home/hitesh/lzma2201/C/Aes.c:133: undefined reference to 'AesCbc_Encode_HW'
/usr/bin/ld: /home/hitesh/lzma2201/C/Aes.c:134: undefined reference to 'AesCtr_Code_HW'
/usr/bin/ld: /home/hitesh/lzma2201/C/Aes.c:142: undefined reference to 'AesCbc_Decode_HW_256'
/usr/bin/ld: /home/hitesh/lzma2201/C/Aes.c:144: undefined reference to 'AesCtr_Code_HW_256'
/usr/bin/ld: LzFindMt.o: in function 'BtGetMatches(_CMatchFinderMt*, unsigned int*)':
/home/hitesh/lzma2201/C/LzFindMt.c:686: undefined reference to 'GetMatchesSpecN_2(unsigned char const*, unsigned long, unsigned char const*, unsigned int*, unsigned int, unsigned int*, unsigned long, unsigned int const*, unsigned int const*, unsigned int const*, unsigned long, unsigned int, unsigned int*)'
/usr/bin/ld: Sha256.o: in function 'Sha256Prepare':
/home/hitesh/lzma2201/C/Sha256.c:481: undefined reference to 'Sha256_UpdateBlocks_HW(unsigned int*, unsigned char const*, unsigned long)'
collect2: error: ld returned 1 exit status

here is the script used to compile the program. run2.sh

for FILE in $(ls "/home/hitesh/lzma2201/C" | egrep '\.c$');
    do 
    g++ -Wall -std=c++14 -g -c -D_7ZIP_ST -I"/home/hitesh/lzma2201/C" "/home/hitesh/lzma2201/C/"$FILE ; 
done
g++ -std=c++14  -Wall -nostartfiles -g 7zAlloc.o 7zArcIn.o 7zBuf.o 7zBuf2.o 7zCrc.o 7zCrcOpt.o 7zDec.o 7zFile.o 7zStream.o Aes.o AesOpt.o Alloc.o Bcj2.o Bcj2Enc.o Bra.o Bra86.o BraIA64.o CpuArch.o Delta.o DllSecur.o LzFind.o LzFindMt.o Lzma2Dec.o Lzma2DecMt.o Lzma2Enc.o Lzma86Dec.o Lzma86Enc.o LzmaDec.o LzmaEnc.o LzmaLib.o MtCoder.o MtDec.o Ppmd7.o Ppmd7Dec.o Ppmd7Enc.o Sha256.o Sort.o  Threads.o Xz.o XzCrc64.o XzCrc64Opt.o XzDec.o XzEnc.o XzIn.o -o compress -L"/home/hitesh/lzma2201/C" 

I have tried using another versions of lzma sdk but that was resulting in different errors. I expected the program to run as it was running when i originally wrote the script in .c file for windows

Botje
  • 26,269
  • 3
  • 31
  • 41
  • I've no idea but what I would do in your situation is look through the code you have for the missing functions. For example can you find a definition for `AesCbc_Decode_HW` in your code? If so then why is it not being compiled, if not then why is it missing? When you get errors like this you have to be a detective. – john Nov 28 '22 at 09:22
  • [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Jesper Juhl Nov 28 '22 at 09:58
  • @john yes ``AesCbc_Decode_HW ``is available in the header file ``Aes.h`` which is included in the ``Aes.c`` , i can post part of code if that helps? – Master Hitesh Nov 28 '22 at 10:15
  • @MasterHitesh The issue is not whether it is available in a header file, because that is only a declaration, the issue is whether it is defined. That would likely only be in a C file. – john Nov 28 '22 at 10:29
  • @MasterHitesh I downloaded the source to take a look. I.m sure the issue is that you are building the source in the wrong way. There are several makefiles present in the download. I expect you should be using one of those instead of writing your own script. – john Nov 28 '22 at 10:36
  • @MasterHitesh For example the makefile in lzmma2201/cpp/build.mak seems to be the one. But I'm not sure, you should try and find some documentation and follow what that says. – john Nov 28 '22 at 10:38

0 Answers0