我正在尝试使用自己的库打包opencv库。 我是这样做的:
ar x libopencv_highgui.a
ar x libopencv_core.a
ar x libopencv_imgproc.a
ar x libmyown.a
ar cru libnew.a *.o
当我使用这个新库libnew.a时,会出现很多这样的错误:
grfmt_bmp.cpp :(。text._ZN2cv10BmpDecoder8readDataERNS_3MatE + 0x282):未定义引用CvtPaletteToGray(PaletteEntry const*, unsigned char*, int)'
grfmt_bmp.cpp:(.text._ZN2cv10BmpDecoder8readDataERNS_3MatE+0x321): undefined reference to
FillColorRow1(unsigned char *,unsigned char *,int,PaletteEntry *)'
grfmt_bmp.cpp :(。text._ZN2cv10BmpDecoder8readDataERNS_3MatE + 0x376):未定义引用FillColorRow1(unsigned char*, unsigned char*, int, PaletteEntry*)'
grfmt_bmp.cpp:(.text._ZN2cv10BmpDecoder8readDataERNS_3MatE+0x3b5): undefined reference to
icvCvt_BGR2Gray_8u_C3C1R(unsigned char const *,int,unsigned char *,int,CvSize,int)'
grfmt_bmp.cpp :(。text._ZN2cv10BmpDecoder8readDataERNS_3MatE + 0x449):未定义引用FillGrayRow4(unsigned char*, unsigned char*, int, unsigned char*)'
grfmt_bmp.cpp:(.text._ZN2cv10BmpDecoder8readDataERNS_3MatE+0x492): undefined reference to
FillColorRow4(unsigned char *,unsigned char *,int,PaletteEntry *)'
grfmt_bmp.cpp :(。text._ZN2cv10BmpDecoder8readDataERNS_3MatE + 0x524):未定义引用FillGrayRow8(unsigned char*, unsigned char*, int, unsigned char*)'
grfmt_bmp.cpp:(.text._ZN2cv10BmpDecoder8readDataERNS_3MatE+0x567): undefined reference to
FillColorRow8(unsigned char *,unsigned char *,int,PaletteEntry *)'
grfmt_bmp.cpp :(。text._ZN2cv10BmpDecoder8readDataERNS_3MatE + 0x5f9):未定义引用icvCvt_BGR5552BGR_8u_C2C3R(unsigned char const*, int, unsigned char*, int, CvSize)'
grfmt_bmp.cpp:(.text._ZN2cv10BmpDecoder8readDataERNS_3MatE+0x669): undefined reference to
icvCvt_BGR5552Gray_8u_C2C1R(unsigned char const *,int,unsigned char *,int,CvSize)'
grfmt_bmp.cpp :(。text._ZN2cv10BmpDecoder8readDataERNS_3MatE + 0x6fa):未定义引用icvCvt_BGR5652BGR_8u_C2C3R(unsigned char const*, int, unsigned char*, int, CvSize)'
grfmt_bmp.cpp:(.text._ZN2cv10BmpDecoder8readDataERNS_3MatE+0x769): undefined reference to
icvCvt_BGR5652Gray_8u_C2C1R(unsigned char const *,int,unsigned char *,int,CvSize)'
grfmt_bmp.cpp :(。text._ZN2cv10BmpDecoder8readDataERNS_3MatE + 0x843):未定义引用icvCvt_BGR2Gray_8u_C3C1R(unsigned char const*, int, unsigned char*, int, CvSize, int)'
grfmt_bmp.cpp:(.text._ZN2cv10BmpDecoder8readDataERNS_3MatE+0x8dc): undefined reference to
icvCvt_BGRA2BGR_8u_C4C3R(unsigned char const *,int,unsigned char *,int,CvSize,int)'
grfmt_bmp.cpp :(。text._ZN2cv10BmpDecoder8readDataERNS_3MatE + 0x94c):未定义引用icvCvt_BGRA2Gray_8u_C4C1R(unsigned char const*, int, unsigned char*, int, CvSize, int)'
grfmt_bmp.cpp:(.text._ZN2cv10BmpDecoder8readDataERNS_3MatE+0xa2c): undefined reference to
FillUniColor(unsigned char *,unsigned char *&,int,int,int&,int,int,PaletteEntry)'
grfmt_bmp.cpp :(。text._ZN2cv10BmpDecoder8readDataERNS_3MatE + 0xaba):未定义引用FillColorRow8(unsigned char*, unsigned char*, int, PaletteEntry*)'
grfmt_bmp.cpp:(.text._ZN2cv10BmpDecoder8readDataERNS_3MatE+0xb4a): undefined reference to
FillUniGray(unsigned char *,unsigned char *&,int,int,int&,int,int,unsigned char)&#39 ;
grfmt_bmp.cpp :(。text._ZN2cv10BmpDecoder8readDataERNS_3MatE + 0xbad):对FillUniColor(unsigned char*, unsigned char*&, int, int, int&, int, int, PaletteEntry)'
grfmt_bmp.cpp:(.text._ZN2cv10BmpDecoder8readDataERNS_3MatE+0xc15): undefined reference to
的未定义引用FillGrayRow8(unsigned char *,unsigned char *,int,unsigned char *)'
grfmt_bmp.cpp :(。text._ZN2cv10BmpDecoder8readDataERNS_3MatE + 0xc46):未定义引用FillUniGray(unsigned char*, unsigned char*&, int, int, int&, int, int, unsigned char)'
grfmt_bmp.cpp:(.text._ZN2cv10BmpDecoder8readDataERNS_3MatE+0xe18): undefined reference to
FillColorRow4(unsigned char *,unsigned char *,int,PaletteEntry *)'
grfmt_bmp.cpp :(。text._ZN2cv10BmpDecoder8readDataERNS_3MatE + 0xe6a):未定义引用FillUniColor(unsigned char*, unsigned char*&, int, int, int&, int, int, PaletteEntry)'
grfmt_bmp.cpp:(.text._ZN2cv10BmpDecoder8readDataERNS_3MatE+0xeb3): undefined reference to
FillUniGray(unsigned char *,unsigned char *&,int,int,int&,int,int,unsigned char)&#39 ;
grfmt_bmp.cpp :(。text._ZN2cv10BmpDecoder8readDataERNS_3MatE + 0xecb):未定义引用FillGrayRow4(unsigned char*, unsigned char*, int, unsigned char*)'
./lib/libbasmk.a(grfmt_jpeg.cpp.o): In function
cv :: JpegDecoder :: readData(cv :: Mat&)':
grfmt_jpeg.cpp :(。text._ZN2cv11JpegDecoder8readDataERNS_3MatE + 0x1b4):未定义引用icvCvt_CMYK2BGR_8u_C4C3R(unsigned char const*, int, unsigned char*, int, CvSize)'
grfmt_jpeg.cpp:(.text._ZN2cv11JpegDecoder8readDataERNS_3MatE+0x221): undefined reference to
icvCvt_CMYK2Gray_8u_C4C1R(unsigned char const *,int,unsigned char *,int,CvSize)'
grfmt_jpeg.cpp :(。text._ZN2cv11JpegDecoder8readDataERNS_3MatE + 0x254):未定义引用icvCvt_BGR2RGB_8u_C3R(unsigned char const*, int, unsigned char*, int, CvSize)'
./lib/libbasmk.a(grfmt_jpeg.cpp.o): In function
cv :: JpegEncoder :: write(cv :: Mat const&,std :: vector> const&)':
grfmt_jpeg.cpp :(。text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE + 0x49a):未定义引用icvCvt_BGR2RGB_8u_C3R(unsigned char const*, int, unsigned char*, int, CvSize)'
grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x510): undefined reference to
icvCvt_BGRA2BGR_8u_C4C3R(unsigned char const *,int,unsigned char *,int,CvSize,int)'
./lib/libbasmk.a(grfmt_pxm.cpp.o):在函数cv::PxMEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)':
grfmt_pxm.cpp:(.text._ZN2cv10PxMEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x437): undefined reference to
icvCvt_BGR2RGB_16u_C3R(unsigned short const *,int,unsigned short *,int,CvSize)&#39;
grfmt_pxm.cpp :(。text._ZN2cv10PxMEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE + 0x539):未定义引用icvCvt_BGR2RGB_8u_C3R(unsigned char const*, int, unsigned char*, int, CvSize)'
./lib/libbasmk.a(grfmt_pxm.cpp.o): In function
cv :: PxMDecoder :: readData(cv :: Mat&amp;)&#39;:
grfmt_pxm.cpp :(。text._ZN2cv10PxMDecoder8readDataERNS_3MatE + 0x30d):未定义引用FillGrayPalette(PaletteEntry*, int, bool)'
grfmt_pxm.cpp:(.text._ZN2cv10PxMDecoder8readDataERNS_3MatE+0x410): undefined reference to
icvCvt_BGR2RGB_8u_C3R(unsigned char const *,int,unsigned char *,int,CvSize)&#39;
grfmt_pxm.cpp :(。text._ZN2cv10PxMDecoder8readDataERNS_3MatE + 0x4ee):未定义引用icvCvt_BGR2Gray_8u_C3C1R(unsigned char const*, int, unsigned char*, int, CvSize, int)'
grfmt_pxm.cpp:(.text._ZN2cv10PxMDecoder8readDataERNS_3MatE+0x5af): undefined reference to
icvCvt_BGR2RGB_16u_C3R(unsigned short const *,int,unsigned short *,int,CvSize)&#39;
grfmt_pxm.cpp :(。text._ZN2cv10PxMDecoder8readDataERNS_3MatE + 0x60c):对icvCvt_BGRA2Gray_16u_CnC1R(unsigned short const*, int, unsigned short*, int, CvSize, int, int)'
grfmt_pxm.cpp:(.text._ZN2cv10PxMDecoder8readDataERNS_3MatE+0x6fa): undefined reference to
的未定义引用FillGrayRow1(unsigned char *,unsigned char *,int,unsigned char *)&#39;
grfmt_pxm.cpp :(。text._ZN2cv10PxMDecoder8readDataERNS_3MatE + 0x766):未定义引用FillColorRow8(unsigned char*, unsigned char*, int, PaletteEntry*)'
grfmt_pxm.cpp:(.text._ZN2cv10PxMDecoder8readDataERNS_3MatE+0x7a9): undefined reference to
FillColorRow1(unsigned char *,unsigned char *,int,PaletteEntry *)&#39;
grfmt_pxm.cpp :(。text._ZN2cv10PxMDecoder8readDataERNS_3MatE + 0x7d1):对FillGrayRow8(unsigned char*, unsigned char*, int, unsigned char*)'
./lib/libbasmk.a(grfmt_sunras.cpp.o): In function
cv :: SunRasterDecoder :: readHeader()&#39;的未定义引用:
grfmt_sunras.cpp :(。text._ZN2cv16SunRasterDecoder10readHeaderEv + 0x248):未定义引用IsColorPalette(PaletteEntry*, int)'
grfmt_sunras.cpp:(.text._ZN2cv16SunRasterDecoder10readHeaderEv+0x278): undefined reference to
FillGrayPalette(PaletteEntry *,int,bool)&#39;
./lib/libbasmk.a(grfmt_sunras.cpp.o):在函数cv::SunRasterDecoder::readData(cv::Mat&)':
grfmt_sunras.cpp:(.text._ZN2cv16SunRasterDecoder8readDataERNS_3MatE+0x2ea): undefined reference to
FillGrayRow1(unsigned char *,unsigned char *,int,unsigned char *)&#39;
grfmt_sunras.cpp :(。text._ZN2cv16SunRasterDecoder8readDataERNS_3MatE + 0x37c):未定义引用FillGrayRow8(unsigned char*, unsigned char*, int, unsigned char*)'
grfmt_sunras.cpp:(.text._ZN2cv16SunRasterDecoder8readDataERNS_3MatE+0x3ca): undefined reference to
FillColorRow8(unsigned char *,unsigned char *,int,PaletteEntry *)&#39;
grfmt_sunras.cpp :(。text._ZN2cv16SunRasterDecoder8readDataERNS_3MatE + 0x41a):未定义引用FillColorRow1(unsigned char*, unsigned char*, int, PaletteEntry*)'
grfmt_sunras.cpp:(.text._ZN2cv16SunRasterDecoder8readDataERNS_3MatE+0x45e): undefined reference to
CvtPaletteToGray(PaletteEntry const *,unsigned char *,int)&#39;
grfmt_sunras.cpp :(。text._ZN2cv16SunRasterDecoder8readDataERNS_3MatE + 0x4e2):未定义引用icvCvt_BGRA2BGR_8u_C4C3R(unsigned char const*, int, unsigned char*, int, CvSize, int)'
grfmt_sunras.cpp:(.text._ZN2cv16SunRasterDecoder8readDataERNS_3MatE+0x573): undefined reference to
icvCvt_BGRA2Gray_8u_C4C1R(unsigned char const *,int,unsigned char *,int,CvSize,int)&#39;
grfmt_sunras.cpp :(。text._ZN2cv16SunRasterDecoder8readDataERNS_3MatE + 0x641):对icvCvt_BGR2Gray_8u_C3C1R(unsigned char const*, int, unsigned char*, int, CvSize, int)'
fmt_sunras.cpp:(.text._ZN2cv16SunRasterDecoder8readDataERNS_3MatE+0x677): undefined reference to
的未定义引用icvCvt_BGR2RGB_8u_C3R(unsigned char const *,int,unsigned char *,int,CvSize)%n
grfmt_sunras.cpp :(。text._ZN2cv16SunRasterDecoder8readDataERNS_3MatE + 0x757):未定义引用FillColorRow8(unsigned char*, unsigned char*, int, PaletteEntry*)'
grfmt_sunras.cpp:(.text._ZN2cv16SunRasterDecoder8readDataERNS_3MatE+0x7bc): undefined reference to
FillUniColor(unsigned char *,unsigned char *&amp;,int,int,int&amp;,int,int,PaletteEntry)&#39;
grfmt_sunras.cpp :(。text._ZN2cv16SunRasterDecoder8readDataERNS_3MatE + 0x85d):未定义引用FillGrayRow8(unsigned char*, unsigned char*, int, unsigned char*)'
grfmt_sunras.cpp:(.text._ZN2cv16SunRasterDecoder8readDataERNS_3MatE+0x898): undefined reference to
FillUniGray(unsigned char *,unsigned char *&amp;,int,int,int&amp;,int,int,unsigned char)&#39 ;
grfmt_sunras.cpp :(。text._ZN2cv16SunRasterDecoder8readDataERNS_3MatE + 0x985):对FillColorRow1(unsigned char*, unsigned char*, int, PaletteEntry*)'
grfmt_sunras.cpp:(.text._ZN2cv16SunRasterDecoder8readDataERNS_3MatE+0x9df): undefined reference to
的未定义引用FillGrayRow1(unsigned char *,unsigned char *,int,unsigned char *)&#39;
./lib/libbasmk.a(grfmt_tiff.cpp.o):在函数cv::TiffDecoder::readData(cv::Mat&)':
grfmt_tiff.cpp:(.text._ZN2cv11TiffDecoder8readDataERNS_3MatE+0x600): undefined reference to
icvCvt_BGRA2Gray_8u_C4C1R(unsigned char const *,int,unsigned char *,int,CvSize,int)&#39;
grfmt_tiff.cpp :(。text._ZN2cv11TiffDecoder8readDataERNS_3MatE + 0x67e):未定义引用icvCvt_BGRA2BGR_8u_C4C3R(unsigned char const*, int, unsigned char*, int, CvSize, int)'
grfmt_tiff.cpp:(.text._ZN2cv11TiffDecoder8readDataERNS_3MatE+0x792): undefined reference to
icvCvt_BGRA2BGR_16u_C4C3R(unsigned short const *,int,unsigned short *,int,CvSize,int)&#39;
grfmt_tiff.cpp :(。text._ZN2cv11TiffDecoder8readDataERNS_3MatE + 0x823):未定义引用icvCvt_BGRA2Gray_16u_CnC1R(unsigned short const*, int, unsigned short*, int, CvSize, int, int)'
grfmt_tiff.cpp:(.text._ZN2cv11TiffDecoder8readDataERNS_3MatE+0x8b9): undefined reference to
icvCvt_BGR2RGB_16u_C3R(unsigned short const *,int,unsigned short *,int,CvSize)&#39;
grfmt_tiff.cpp :(。text._ZN2cv11TiffDecoder8readDataERNS_3MatE + 0x917):未定义引用icvCvt_Gray2BGR_16u_C1C3R(unsigned short const*, int, unsigned short*, int, CvSize)'
./lib/libbasmk.a(grfmt_tiff.cpp.o): In function
cv :: TiffEncoder :: writeLibTiff(cv :: Mat const&amp;,std :: vector&gt; const&amp;)&#39;:
grfmt_tiff.cpp :(。text._ZN2cv11TiffEncoder12writeLibTiffERKNS_3MatERKSt6vectorIiSaIiEE + 0x432):未定义引用icvCvt_BGR2RGB_8u_C3R(unsigned char const*, int, unsigned char*, int, CvSize)'
grfmt_tiff.cpp:(.text._ZN2cv11TiffEncoder12writeLibTiffERKNS_3MatERKSt6vectorIiSaIiEE+0x488): undefined reference to
icvCvt_BGRA2RGBA_8u_C4R(unsigned char const *,int,unsigned char *,int,CvSize)&#39;
grfmt_tiff.cpp :(。text._ZN2cv11TiffEncoder12writeLibTiffERKNS_3MatERKSt6vectorIiSaIiEE + 0x4d2):未定义引用icvCvt_BGR2RGB_16u_C3R(unsigned short const*, int, unsigned short*, int, CvSize)'
grfmt_tiff.cpp:(.text._ZN2cv11TiffEncoder12writeLibTiffERKNS_3MatERKSt6vectorIiSaIiEE+0x51c): undefined reference to
icvCvt_BGRA2RGBA_16u_C4R(unsigned short const *,int,unsigned short *,int,CvSize)&#39;
./lib/libbasmk.a(grfmt_tiff.cpp.o):在函数cv::TiffEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)':
grfmt_tiff.cpp:(.text._ZN2cv11TiffEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x358): undefined reference to
icvCvt_BGR2RGB_8u_C3R(unsigned char const *,int,unsigned char *,int,CvSize)&#39;
grfmt_tiff.cpp :(。text._ZN2cv11TiffEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE + 0x6e0):未定义引用icvCvt_BGRA2RGBA_8u_C4R(unsigned char const*, int, unsigned char*, int, CvSize)'
grfmt_tiff.cpp:(.text._ZN2cv11TiffEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x733): undefined reference to
icvCvt_BGR2RGB_16u_C3R(unsigned short const *,int,unsigned short *,int,CvSize)&#39;
grfmt_tiff.cpp :(。text._ZN2cv11TiffEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE + 0x794):未定义的引用`icvCvt_BGRA2RGBA_16u_C4R(unsigned short const *,int,unsigned short *,int,CvSize)&#39;
答案 0 :(得分:1)
opencv_imgproc
和opencv_highgui
模块具有相同名称的源文件(例如,util.cpp
)。来自util.o
的目标文件opencv_highgui
将被opencv_imgproc
中具有相同名称的目标文件覆盖。这就是你遇到链接错误的原因。
尝试使用AR工具的MRI脚本模式。使用以下内容创建MRI脚本文件(例如,script.mri
):
create libnew.a
addlib libopencv_core.a
addlib libopencv_imgproc.a
addlib libopencv_highgui.a
addlib libmyown.a
save
end
并将其与ar
工具一起使用:
ar -M <script.mri