尝试在Cygwin64中使用时遇到以下链接错误。我的PATH解释了libbz2.a和libbz2.dll的位置。
$ gcc -lbz2 bzlibExample.c -o bzlibExample
/tmp/ccz9P7fm.o:bzlibExample.c:(.text+0x18b): undefined reference to `BZ2_bzWriteOpen'
/tmp/ccz9P7fm.o:bzlibExample.c:(.text+0x18b): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `BZ2_bzWriteOpen'
/tmp/ccz9P7fm.o:bzlibExample.c:(.text+0x1ef): undefined reference to `BZ2_bzWrite'
/tmp/ccz9P7fm.o:bzlibExample.c:(.text+0x1ef): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `BZ2_bzWrite'
/tmp/ccz9P7fm.o:bzlibExample.c:(.text+0x233): undefined reference to `BZ2_bzWriteClose'
/tmp/ccz9P7fm.o:bzlibExample.c:(.text+0x233): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `BZ2_bzWriteClose'
/tmp/ccz9P7fm.o:bzlibExample.c:(.text+0x2bb): undefined reference to `BZ2_bzWriteClose'
/tmp/ccz9P7fm.o:bzlibExample.c:(.text+0x2bb): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `BZ2_bzWriteClose'
collect2: error: ld returned 1 exit status
感谢任何帮助。