如何修复 C++ 链接错误:undefined reference to symbol 'crc32'
问题:
尝试编译 C++ 程序时,在链接阶段,你看到类似这样的错误消息
error.txt
/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解决方案
crc32 符号在 zlib 中定义。因此,你需要通过添加来链接 zlib
linker_flags.txt
-lz到你的链接器标志。如果你不知道链接器标志在哪里,尝试直接添加到编译器标志。
Check out similar posts by category:
C/C++, GCC Errors
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow