对"libiconv_close"的未定义引用

undefined reference to `libiconv_close'

本文关键字:未定义 引用 libiconv close      更新时间:2023-10-16

我正在尝试使用mingw构建zxing,但是它失败了,错误 undefined reference to libiconv_close

这是构建的输出:

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o buildzxing.exe -Ldl -L/usr/lib -LC:/MinGW/msys/1.0/local/lib -liconv buildmagicksrcMagickBitmapSource.o buildmagicksrcmain.o buildlibzxing.a -lMagick++ -lMagickWand -lMagickCore
buildlibzxing.a(Decoder.o): In function `add':
C:WorkspaceBarCodeszxing-2.1cpp/build/core/src/zxing/aztec/decoder/Decoder.cpp:51: undefined reference to `libiconv_open'
C:WorkspaceBarCodeszxing-2.1cpp/build/core/src/zxing/aztec/decoder/Decoder.cpp:52: undefined reference to `libiconv'
C:WorkspaceBarCodeszxing-2.1cpp/build/core/src/zxing/aztec/decoder/Decoder.cpp:53: undefined reference to `libiconv_close'
buildlibzxing.a(DecodedBitStreamParser.o): In function `ZN5zxing6qrcode22DecodedBitStreamParser6appendERSsPKhjPKc':
C:WorkspaceBarCodeszxing-2.1cpp/build/core/src/zxing/qrcode/decoder/DecodedBitStreamParser.cpp:70: undefined reference to `libiconv_open'
C:WorkspaceBarCodeszxing-2.1cpp/build/core/src/zxing/qrcode/decoder/DecodedBitStreamParser.cpp:85: undefined reference to `libiconv'
C:WorkspaceBarCodeszxing-2.1cpp/build/core/src/zxing/qrcode/decoder/DecodedBitStreamParser.cpp:87: undefined reference to `libiconv_close'
C:WorkspaceBarCodeszxing-2.1cpp/build/core/src/zxing/qrcode/decoder/DecodedBitStreamParser.cpp:92: undefined reference to `libiconv_close'
collect2: ld returned 1 exit status
scons: *** [buildzxing.exe] Error 1
scons: building terminated because of errors.

问题是由于链接顺序, -liconv需要在命令行中的 buildlibzxing.a之后,如@mat所说。