How to fix C++ linking error: undefined reference to symbol 'crc32'
Problem:
While trying to compile your C++ program, during the linking stage, you see an error message such as
/bin/ld: minio-cpp/src/utils.o: undefined reference to symbol 'crc32'
/bin/ld: /lib/x86_64-linux-gnu/libz.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Solution
TheĀ crc32
symbol is defined in zlib
. Hence, you need to link zlib
by adding
-lz
to your linker flags. If you don’t know where your linker flags are, try just adding it to your compiler flags.