Mingw 和 libraw 导致未定义的引用

Mingw and libraw results in undefined reference

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

有人在mingw中使用libraw吗?我正在尝试编译程序并收到以下错误:

objReleaseincimgcimg.o:cimg.cpp|| undefined reference to `_imp___ZN6LibRawC1Ej'|
objReleaseincimgcimg.o:cimg.cpp|| undefined reference to `_imp___ZN6LibRaw9open_fileEPKcx'|
objReleaseincimgcimg.o:cimg.cpp|| undefined reference to `_imp___ZN6LibRaw6unpackEv'|
objReleaseincimgcimg.o:cimg.cpp|| undefined reference to `_imp___ZN6LibRaw13dcraw_processEv'|
objReleaseincimgcimg.o:cimg.cpp|| undefined reference to `_imp___ZN6LibRaw20dcraw_make_mem_imageEPi'|
objReleaseincimgcimg.o:cimg.cpp|| undefined reference to `_imp___ZN6LibRaw7recycleEv'|
objReleaseincimgcimg.o:cimg.cpp:(.text$_ZN6LibRawD1Ev[LibRaw::~LibRaw()]+0xf)||undefined reference to `_imp___ZN6LibRaw7recycleEv'|
||=== Build finished: 7 errors, 0 warnings ===|

我将libraw.a添加到我的项目中。无法弄清楚问题所在。有人知道吗?

从这些符号名称来看,您似乎正在尝试针对 libraw 的 DLL 版本进行编译(由 _imp___ 前缀暗示)。 检查您的 libraw 头文件,并确保函数名称前面没有类似 __declspec(dllimport)__attribute__((dllimport)) 的内容。 这些有时被宏定义隐藏,因此请检查头文件以查看是否有另一个宏可以定义,这将导致它在函数原型中不使用该属性。