Ask Your Question

Revision history [back]

Using Opencv as a static lib on a cross-compiling project

I'm using opencv on a arm board,with a cortex a8 processor and running on Debian.I wanted to use the processor's fpu to increase the performance of my application,so I succesfully cross-compiled opencv (following this guide) using a toolchain generated for this purpose.

With that said,I dont have experience with working with static libraries.When I compile my code,I get a lot of linking errors.Apparently,they are related with zlib or zlib2,as I've seen on this topic.The thing is,I didn't enabled the png support,but I still get those linking errors:

cxpersistence.cpp:(.text._ZL8icvCloseP13CvFileStorage+0x24): undefined reference to `gzclose'
/cv-lib-arm-hf/lib/libcxcore.a(cxpersistence.o): In function `icvPuts(CvFileStorage*, char const*)':
cxpersistence.cpp:(.text._ZL7icvPutsP13CvFileStoragePKc+0x3c): undefined reference to `gzputs'
/cv-lib-arm-hf/lib/libcxcore.a(cxpersistence.o): In function `icvGets(CvFileStorage*, char*, int)':
cxpersistence.cpp:(.text._ZL7icvGetsP13CvFileStoragePci+0x4c): undefined reference to `gzgets'
/cv-lib-arm-hf/lib/libcxcore.a(cxpersistence.o): In function `icvEof(CvFileStorage*)':
cxpersistence.cpp:(.text._ZL6icvEofP13CvFileStorage+0x30): undefined reference to `gzeof'
cxpersistence.cpp:(.text._ZL6icvEofP13CvFileStorage+0xc4): undefined reference to `gzeof'
/cv-lib-arm-hf/lib/libcxcore.a(cxpersistence.o): In function `cvOpenFileStorage':
cxpersistence.cpp:(.text.cvOpenFileStorage+0x674): undefined reference to `gzopen'
cxpersistence.cpp:(.text.cvOpenFileStorage+0xae8): undefined reference to `gzrewind'
cxpersistence.cpp:(.text.cvOpenFileStorage+0xb98): undefined reference to `gzrewind'
/cv-lib-arm-hf/lib/libcxcore.a(cxlapack.o): In function `cv::SVD::operator()(cv::Mat const&, int)':
cxlapack.cpp:(.text._ZN2cv3SVDclERKNS_3MatEi+0x2b0): undefined reference to `dgesdd_'
cxlapack.cpp:(.text._ZN2cv3SVDclERKNS_3MatEi+0x4b8): undefined reference to `dgesdd_'
cxlapack.cpp:(.text._ZN2cv3SVDclERKNS_3MatEi+0x74c): undefined reference to `sgesdd_'
cxlapack.cpp:(.text._ZN2cv3SVDclERKNS_3MatEi+0x874): undefined reference to `sgesdd_'
/cv-lib-arm-hf/lib/libcxcore.a(cxlapack.o): In function `cv::eigen(cv::Mat const&, cv::Mat&, cv::Mat&, bool, int, int)':
cxlapack.cpp:(.text._ZN2cvL5eigenERKNS_3MatERS0_S3_bii+0x4bc): undefined reference to `dsyevr_'
cxlapack.cpp:(.text._ZN2cvL5eigenERKNS_3MatERS0_S3_bii+0x66c): undefined reference to `dsyevr_'
cxlapack.cpp:(.text._ZN2cvL5eigenERKNS_3MatERS0_S3_bii+0xa7c): undefined reference to `ssyevr_'
cxlapack.cpp:(.text._ZN2cvL5eigenERKNS_3MatERS0_S3_bii+0xc30): undefined reference to `ssyevr_'
/cv-lib-arm-hf/lib/libcxcore.a(cxlapack.o): In function `cv::solve(cv::Mat const&, cv::Mat const&, cv::Mat&, int)':
cxlapack.cpp:(.text._ZN2cv5solveERKNS_3MatES2_RS0_i+0x760): undefined reference to `dgelsd_'
cxlapack.cpp:(.text._ZN2cv5solveERKNS_3MatES2_RS0_i+0x8fc): undefined reference to `dgelsd_'
cxlapack.cpp:(.text._ZN2cv5solveERKNS_3MatES2_RS0_i+0xb8c): undefined reference to `dgesv_'
cxlapack.cpp:(.text._ZN2cv5solveERKNS_3MatES2_RS0_i+0x1018): undefined reference to `dpotrf_'
cxlapack.cpp:(.text._ZN2cv5solveERKNS_3MatES2_RS0_i+0x105c): undefined reference to `dpotrs_'
cxlapack.cpp:(.text._ZN2cv5solveERKNS_3MatES2_RS0_i+0x10d4): undefined reference to `dgels_'
cxlapack.cpp:(.text._ZN2cv5solveERKNS_3MatES2_RS0_i+0x115c): undefined reference to `dgels_'
cxlapack.cpp:(.text._ZN2cv5solveERKNS_3MatES2_RS0_i+0x11e0): undefined reference to `sgelsd_'
cxlapack.cpp:(.text._ZN2cv5solveERKNS_3MatES2_RS0_i+0x123c): undefined reference to `sgelsd_'
cxlapack.cpp:(.text._ZN2cv5solveERKNS_3MatES2_RS0_i+0x12e0): undefined reference to `spotrf_'
cxlapack.cpp:(.text._ZN2cv5solveERKNS_3MatES2_RS0_i+0x1324): undefined reference to `spotrs_'
cxlapack.cpp:(.text._ZN2cv5solveERKNS_3MatES2_RS0_i+0x1398): undefined reference to `sgels_'
cxlapack.cpp:(.text._ZN2cv5solveERKNS_3MatES2_RS0_i+0x13e8): undefined reference to `sgels_'
cxlapack.cpp:(.text._ZN2cv5solveERKNS_3MatES2_RS0_i+0x1468): undefined reference to `sgesv_'
/cv-lib-arm-hf/lib/libcxcore.a(cxlapack.o): In function `cv::determinant(cv::Mat const&)':
cxlapack.cpp:(.text._ZN2cv11determinantERKNS_3MatE+0x298): undefined reference to `dgetrf_'
cxlapack.cpp:(.text._ZN2cv11determinantERKNS_3MatE+0x40c): undefined reference to `sgetrf_'
/cv-lib-arm-hf/lib/libcxcore.a(cxlapack.o): In function `cv::invert(cv::Mat const&, cv::Mat&, int)':
cxlapack.cpp:(.text._ZN2cv6invertERKNS_3MatERS0_i+0x460): undefined reference to `dgetri_'
cxlapack.cpp:(.text._ZN2cv6invertERKNS_3MatERS0_i+0x4c8): undefined reference to `dgetrf_'
cxlapack.cpp:(.text._ZN2cv6invertERKNS_3MatERS0_i+0x7e4): undefined reference to `dpotrf_'
cxlapack.cpp:(.text._ZN2cv6invertERKNS_3MatERS0_i+0x82c): undefined reference to `sgetri_'
cxlapack.cpp:(.text._ZN2cv6invertERKNS_3MatERS0_i+0xa78): undefined reference to `sgetrf_'
cxlapack.cpp:(.text._ZN2cv6invertERKNS_3MatERS0_i+0xab0): undefined reference to `sgetri_'
cxlapack.cpp:(.text._ZN2cv6invertERKNS_3MatERS0_i+0xaf8): undefined reference to `dgetri_'
cxlapack.cpp:(.text._ZN2cv6invertERKNS_3MatERS0_i+0xb28): undefined reference to `spotrf_'
cxlapack.cpp:(.text._ZN2cv6invertERKNS_3MatERS0_i+0xb5c): undefined reference to `spotri_'
cxlapack.cpp:(.text._ZN2cv6invertERKNS_3MatERS0_i+0xb84): undefined reference to `dpotri_'

I also tried compiling zlib and bzip2 myself,using the same toolchain,but the error persists.Now I have no idea of what I'm doing wrong.Can anyone help?