0

I compile OpenCV4 by statically link:

cmake -DCMAKE_TOOLCHAIN_FILE=../platforms/linux/arm-gnueabi.toolchain.cmake -DCMAKE_INSTALL_PREFIX=~/opencv4-static -DBUILD_SHARED_LIBS=OFF -DBUILD_WITH_STATIC_CRT=ON -DCMAKE_BUILD_TYPE=RELEASE -DOPENCV_GENERATE_PKGCONFIG=ON ../

add the pkgconfig in the path:

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/atmark/opencv4-static/lib/pkgconfig

then compile a sample:

arm-linux-gnueabihf-g++-4.9 -std=c++11 videocapture_basic.cpp -o camera `pkg-config opencv4 --cflags --libs --static`

but got a lot of errors:

/home/atmark/opencv4-static/lib/libopencv_imgcodecs.a(grfmt_exr.cpp.o): undefined reference to `cv::ExrDecoder::readHeader()' :
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder10readHeaderEv+0x6): `Imf::globalThreadCount()' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder10readHeaderEv+0x18): `Imf::InputFile::InputFile(char const*, int)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder10readHeaderEv+0x20): `Imf::InputFile::header() const' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder10readHeaderEv+0x26): `Imf::Header::dataWindow() const' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder10readHeaderEv+0x4e): `Imf::InputFile::header() const' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder10readHeaderEv+0x52): `Imf::hasChromaticities(Imf::Header const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder10readHeaderEv+0x5a): `Imf::InputFile::header() const' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder10readHeaderEv+0x5e): `Imf::Header::channels() const' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder10readHeaderEv+0x68): `Imf::ChannelList::findChannel(char const*) const' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder10readHeaderEv+0x74): `Imf::ChannelList::findChannel(char const*) const' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder10readHeaderEv+0x80): `Imf::ChannelList::findChannel(char const*) const' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder10readHeaderEv+0xa8): `Imf::InputFile::header() const' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder10readHeaderEv+0xac): `Imf::chromaticities(Imf::Header const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder10readHeaderEv+0xf8): `Imf::ChannelList::findChannel(char const*) const' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder10readHeaderEv+0x10c): `Imf::ChannelList::findChannel(char const*) const' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder10readHeaderEv+0x118): `Imf::ChannelList::findChannel(char const*) const' 
/home/atmark/opencv4-static/lib/libopencv_imgcodecs.a(grfmt_exr.cpp.o): undefined reference to `cv::ExrDecoder::newDecoder() const' :
grfmt_exr.cpp:(.text._ZNK2cv10ExrDecoder10newDecoderEv+0xba): `Imf::Chromaticities::Chromaticities(Imath::Vec2<float> const&, Imath::Vec2<float> const&, Imath::Vec2<float> const&, Imath::Vec2<float> const&)' 
/home/atmark/opencv4-static/lib/libopencv_imgcodecs.a(grfmt_exr.cpp.o): undefined reference to `cv::ExrDecoder::ExrDecoder()' :
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoderC2Ev+0x84): `Imf::Chromaticities::Chromaticities(Imath::Vec2<float> const&, Imath::Vec2<float> const&, Imath::Vec2<float> const&, Imath::Vec2<float> const&)' 
/home/atmark/opencv4-static/lib/libopencv_imgcodecs.a(grfmt_exr.cpp.o): undefined reference to `cv::ExrDecoder::readData(cv::Mat&)' :
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x140): `Imf::Slice::Slice(Imf::PixelType, char*, unsigned int, unsigned int, int, int, double, bool, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x14c): `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x19c): `Imf::Slice::Slice(Imf::PixelType, char*, unsigned int, unsigned int, int, int, double, bool, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x1a8): `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x1f2): `Imf::Slice::Slice(Imf::PixelType, char*, unsigned int, unsigned int, int, int, double, bool, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x1fe): `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x24e): `Imf::Slice::Slice(Imf::PixelType, char*, unsigned int, unsigned int, int, int, double, bool, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x25a): `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x2aa): `Imf::Slice::Slice(Imf::PixelType, char*, unsigned int, unsigned int, int, int, double, bool, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x2b6): `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x300): `Imf::Slice::Slice(Imf::PixelType, char*, unsigned int, unsigned int, int, int, double, bool, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x30c): `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x31a): `Imf::FrameBuffer::begin()' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x35a): `Imf::FrameBuffer::end()' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x366): `Imf::InputFile::setFrameBuffer(Imf::FrameBuffer const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x3a2): `Imf::InputFile::readPixels(int, int)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x6e0): `Imf::Slice::Slice(Imf::PixelType, char*, unsigned int, unsigned int, int, int, double, bool, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x6ec): `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0x716): `Imf::InputFile::readPixels(int, int)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0xd46): `Imf::Slice::Slice(Imf::PixelType, char*, unsigned int, unsigned int, int, int, double, bool, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0xd52): `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0xd8c): `Imf::Slice::Slice(Imf::PixelType, char*, unsigned int, unsigned int, int, int, double, bool, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0xd98): `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0xdd0): `Imf::Slice::Slice(Imf::PixelType, char*, unsigned int, unsigned int, int, int, double, bool, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0xddc): `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0xe40): `Imf::Slice::Slice(Imf::PixelType, char*, unsigned int, unsigned int, int, int, double, bool, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0xe4c): `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0xe86): `Imf::Slice::Slice(Imf::PixelType, char*, unsigned int, unsigned int, int, int, double, bool, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0xe92): `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0xee0): `Imf::Slice::Slice(Imf::PixelType, char*, unsigned int, unsigned int, int, int, double, bool, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoder8readDataERNS_3MatE+0xeec): `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)' 
/home/atmark/opencv4-static/lib/libopencv_imgcodecs.a(grfmt_exr.cpp.o): undefined reference to `cv::ExrEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)' :
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x54): `Imf::Header::Header(int, int, float, Imath::Vec2<float> const&, float, Imf::LineOrder, Imf::Compression)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0xe0): `Imf::Header::channels()' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0xf2): `Imf::Channel::Channel(Imf::PixelType, int, int, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0xfe): `Imf::ChannelList::insert(char const*, Imf::Channel const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x108): `Imf::globalThreadCount()' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x118): `Imf::OutputFile::OutputFile(char const*, Imf::Header const&, int)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x198): `Imf::Slice::Slice(Imf::PixelType, char*, unsigned int, unsigned int, int, int, double, bool, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x1a8): `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x1b0): `Imf::OutputFile::setFrameBuffer(Imf::FrameBuffer const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x1b8): `Imf::OutputFile::writePixels(int)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x218): `Imf::OutputFile::~OutputFile()' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x21e): `Imf::Header::~Header()' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x252): `Imf::Slice::Slice(Imf::PixelType, char*, unsigned int, unsigned int, int, int, double, bool, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x262): `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x288): `Imf::Slice::Slice(Imf::PixelType, char*, unsigned int, unsigned int, int, int, double, bool, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x294): `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x2b8): `Imf::Slice::Slice(Imf::PixelType, char*, unsigned int, unsigned int, int, int, double, bool, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x2c4): `Imf::FrameBuffer::insert(char const*, Imf::Slice const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x2ca): `Imf::Header::channels()' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x2dc): `Imf::Channel::Channel(Imf::PixelType, int, int, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x2e8): `Imf::ChannelList::insert(char const*, Imf::Channel const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x2ee): `Imf::Header::channels()' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x300): `Imf::Channel::Channel(Imf::PixelType, int, int, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x30c): `Imf::ChannelList::insert(char const*, Imf::Channel const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x312): `Imf::Header::channels()' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x324): `Imf::Channel::Channel(Imf::PixelType, int, int, bool)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x330): `Imf::ChannelList::insert(char const*, Imf::Channel const&)' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x366): `Imf::Header::~Header()' 
grfmt_exr.cpp:(.text._ZN2cv10ExrEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x456): `Imf::OutputFile::~OutputFile()' 
/home/atmark/opencv4-static/lib/libopencv_imgcodecs.a(grfmt_jpeg2000.cpp.o): undefined reference to `cv::JasperInitializer::~JasperInitializer()' :
grfmt_jpeg2000.cpp:(.text._ZN2cv17JasperInitializerD2Ev[_ZN2cv17JasperInitializerD5Ev]+0x4): `jas_cleanup' 
/home/atmark/opencv4-static/lib/libopencv_imgcodecs.a(grfmt_jpeg2000.cpp.o): undefined reference to `cv::Jpeg2KDecoder_close(cv::Jpeg2KDecoder*)' :
grfmt_jpeg2000.cpp:(.text._ZN2cvL19Jpeg2KDecoder_closeEPNS_13Jpeg2KDecoderE+0x8): `jas_stream_close' 
grfmt_jpeg2000.cpp:(.text._ZN2cvL19Jpeg2KDecoder_closeEPNS_13Jpeg2KDecoderE+0x14): `jas_image_destroy' 
/home/atmark/opencv4-static/lib/libopencv_imgcodecs.a(grfmt_jpeg2000.cpp.o): undefined reference to `cv::Jpeg2KDecoder::readHeader()' :
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder10readHeaderEv+0x14): `jas_stream_close' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder10readHeaderEv+0x22): `jas_image_destroy' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder10readHeaderEv+0x32): `jas_stream_fopen' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder10readHeaderEv+0x46): `jas_image_decode' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder10readHeaderEv+0x13e): `jas_stream_close' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder10readHeaderEv+0x14c): `jas_image_destroy' 
/home/atmark/opencv4-static/lib/libopencv_imgcodecs.a(grfmt_jpeg2000.cpp.o): undefined reference to `cv::Jpeg2KDecoder::close()' :
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder5closeEv+0x8): `jas_stream_close' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder5closeEv+0x14): `jas_image_destroy' 
/home/atmark/opencv4-static/lib/libopencv_imgcodecs.a(grfmt_jpeg2000.cpp.o): undefined reference to `cv::Jpeg2KDecoder::readData(cv::Mat&)' :
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder8readDataERNS_3MatE+0xc4): `jas_image_getcmptbytype' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder8readDataERNS_3MatE+0xd0): `jas_image_getcmptbytype' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder8readDataERNS_3MatE+0xdc): `jas_image_getcmptbytype' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder8readDataERNS_3MatE+0x146): `jas_matrix_create' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder8readDataERNS_3MatE+0x160): `jas_image_readcmpt' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder8readDataERNS_3MatE+0x19a): `jas_matrix_destroy' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder8readDataERNS_3MatE+0x2de): `jas_image_getcmptbytype' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder8readDataERNS_3MatE+0x2f0): `jas_cmprof_createfromclrspc' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder8readDataERNS_3MatE+0x302): `jas_image_chclrspc' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder8readDataERNS_3MatE+0x30e): `jas_image_destroy' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder8readDataERNS_3MatE+0x31a): `jas_cmprof_destroy' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder8readDataERNS_3MatE+0x396): `jas_matrix_destroy' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KDecoder8readDataERNS_3MatE+0x408): `jas_cmprof_destroy' 
/home/atmark/opencv4-static/lib/libopencv_imgcodecs.a(grfmt_jpeg2000.cpp.o): undefined reference to `cv::Jpeg2KEncoder::writeComponent8u(void*, cv::Mat const&)' :
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KEncoder16writeComponent8uEPvRKNS_3MatE+0x1e): `jas_matrix_create' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KEncoder16writeComponent8uEPvRKNS_3MatE+0x8a): `jas_image_writecmpt' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KEncoder16writeComponent8uEPvRKNS_3MatE+0xa2): `jas_matrix_destroy' 
/home/atmark/opencv4-static/lib/libopencv_imgcodecs.a(grfmt_jpeg2000.cpp.o): undefined reference to `cv::Jpeg2KEncoder::writeComponent16u(void*, cv::Mat const&)' :
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KEncoder17writeComponent16uEPvRKNS_3MatE+0x20): `jas_matrix_create' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KEncoder17writeComponent16uEPvRKNS_3MatE+0x8c): `jas_image_writecmpt' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KEncoder17writeComponent16uEPvRKNS_3MatE+0xa0): `jas_matrix_destroy' 
/home/atmark/opencv4-static/lib/libopencv_imgcodecs.a(grfmt_jpeg2000.cpp.o): undefined reference to `cv::Jpeg2KEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)' :
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x6c): `jas_image_create' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0xa4): `jas_image_destroy' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0xb8): `jas_image_create' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0xec): `jas_stream_fopen' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0xfa): `jas_image_strtofmt' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x108): `jas_image_encode' 
grfmt_jpeg2000.cpp:(.text._ZN2cv13Jpeg2KEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x114): `jas_stream_close' 
/home/atmark/opencv4-static/lib/libopencv_imgcodecs.a(grfmt_jpeg2000.cpp.o): undefined reference to `_GLOBAL__sub_I_grfmt_jpeg2000.cpp' :
grfmt_jpeg2000.cpp:(.text.startup._GLOBAL__sub_I_grfmt_jpeg2000.cpp+0x2): `jas_init' 
/home/atmark/opencv4-static/lib/libopencv_imgcodecs.a(grfmt_jpeg.cpp.o): undefined reference to `cv::my_jpeg_load_dht(jpeg_decompress_struct*, unsigned char*, JHUFF_TBL**, JHUFF_TBL**) [clone .constprop.59]' :
grfmt_jpeg.cpp:(.text.unlikely._ZN2cvL16my_jpeg_load_dhtEP22jpeg_decompress_structPhPP9JHUFF_TBLS5_.constprop.59+0xaa): `jpeg_alloc_huff_table' 
/home/atmark/opencv4-static/lib/libopencv_imgcodecs.a(grfmt_jpeg.cpp.o): undefined reference to `cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator<int> > const&)' :
grfmt_jpeg.cpp:(.text._ZN2cv11JpegEncoder5writeERKNS_3MatERKSt6vectorIiSaIiEE+0x76): `jpeg_CreateCompress' 
grfmt_jpeg.cpp:
/home/atmark/opencv4-static/lib/libopencv_imgproc.a(color_rgb.cpp.o): undefined reference to `cv::hal::cvtGraytoBGR(unsigned char const*, unsigned int, unsigned char*, unsigned int, int, int, int, int)' :
color_rgb.cpp:(.text._ZN2cv3hal12cvtGraytoBGREPKhjPhjiiii+0x82): `carotene_o4t::isSupportedConfiguration()' 
/home/atmark/opencv4-static/lib/libopencv_imgproc.a(color_yuv.cpp.o): undefined reference to `TegraCvtColor_rgb2ycrcb_Invoker::operator()(cv::Range const&) const' :
color_yuv.cpp:(.text._ZNK31TegraCvtColor_rgb2ycrcb_InvokerclERKN2cv5RangeE[_ZNK31TegraCvtColor_rgb2ycrcb_InvokerclERKN2cv5RangeE]+0x2a): `carotene_o4t::rgb2ycrcb(carotene_o4t::Size2D const&, unsigned char const*, int, unsigned char*, int)' 
/home/atmark/opencv4-static/lib/libopencv_imgproc.a(color_yuv.cpp.o): undefined reference to `TegraCvtColor_bgr2ycrcb_Invoker::operator()(cv::Range const&) const' :
color_yuv.cpp:(.text._ZNK31TegraCvtColor_bgr2ycrcb_InvokerclERKN2cv5RangeE[_ZNK31TegraCvtColor_bgr2ycrcb_InvokerclERKN2cv5RangeE]+0x2a): `carotene_o4t::bgr2ycrcb(carotene_o4t::Size2D const&, unsigned char const*, int, unsigned char*, int)' 
/home/atmark/opencv4-static/lib/libopencv_imgproc.a(color_yuv.cpp.o): undefined reference to `TegraCvtColor_rgbx2ycrcb_Invoker::operator()(cv::Range const&) const' :
color_yuv.cpp:(.text._ZNK32TegraCvtColor_rgbx2ycrcb_InvokerclERKN2cv5RangeE[_ZNK32TegraCvtColor_rgbx2ycrcb_InvokerclERKN2cv5RangeE]+0x2a): `carotene_o4t::rgbx2ycrcb(carotene_o4t::Size2D const&, unsigned char const*, int, unsigned char*, int)' 
/home/atmark/opencv4-static/lib/libopencv_imgproc.a(color_yuv.cpp.o): undefined reference to `TegraCvtColor_bgrx2ycrcb_Invoker::operator()(cv::Range const&) const' :
color_yuv.cpp:(.text._ZNK32TegraCvtColor_bgrx2ycrcb_InvokerclERKN2cv5RangeE[_ZNK32TegraCvtColor_bgrx2ycrcb_InvokerclERKN2cv5RangeE]+0x2a): `carotene_o4t::bgrx2ycrcb(carotene_o4t::Size2D const&, unsigned char const*, int, unsigned char*, int)' 
/home/atmark/opencv4-static/lib/libopencv_imgproc.a(color_yuv.cpp.o): undefined reference to `cv::hal::cvtBGRtoYUV(unsigned char const*, unsigned int, unsigned char*, unsigned int, int, int, int, int, bool, bool)' :
color_yuv.cpp:(.text._ZN2cv3hal11cvtBGRtoYUVEPKhjPhjiiiibb+0xd2): `carotene_o4t::isSupportedConfiguration()' 
/home/atmark/opencv4-static/lib/libopencv_imgproc.a(color_yuv.cpp.o): undefined reference to `cv::hal::cvtTwoPlaneYUVtoBGR(unsigned char const*, unsigned int, unsigned char*, unsigned int, int, int, int, bool, int)' :
color_yuv.cpp:(.text._ZN2cv3hal19cvtTwoPlaneYUVtoBGREPKhjPhjiiibi+0x22): `carotene_o4t::isSupportedConfiguration()' 
color_yuv.cpp:(.text._ZN2cv3hal19cvtTwoPlaneYUVtoBGREPKhjPhjiiibi+0x88): `carotene_o4t::yuv420i2bgr(carotene_o4t::Size2D const&, unsigned char const*, int, unsigned char const*, int, unsigned char*, int)' 
color_yuv.cpp:(.text._ZN2cv3hal19cvtTwoPlaneYUVtoBGREPKhjPhjiiibi+0xc2): `carotene_o4t::yuv420i2rgbx(carotene_o4t::Size2D const&, unsigned char const*, int, unsigned char const*, int, unsigned char*, int)' 
color_yuv.cpp:(.text._ZN2cv3hal19cvtTwoPlaneYUVtoBGREPKhjPhjiiibi+0xec): `carotene_o4t::yuv420sp2rgb(carotene_o4t::Size2D const&, unsigned char const*, int, unsigned char const*, int, unsigned char*, int)' 
color_yuv.cpp:(.text._ZN2cv3hal19cvtTwoPlaneYUVtoBGREPKhjPhjiiibi+0x116): `carotene_o4t::yuv420sp2rgbx(carotene_o4t::Size2D const&, unsigned char const*, int, unsigned char const*, int, unsigned char*, int)' 
color_yuv.cpp:(.text._ZN2cv3hal19cvtTwoPlaneYUVtoBGREPKhjPhjiiibi+0x128): `carotene_o4t::yuv420i2rgb(carotene_o4t::Size2D const&, unsigned char const*, int, unsigned char const*, int, unsigned char*, int)' 
color_yuv.cpp:(.text._ZN2cv3hal19cvtTwoPlaneYUVtoBGREPKhjPhjiiibi+0x13a): `carotene_o4t::yuv420i2bgrx(carotene_o4t::Size2D const&, unsigned char const*, int, unsigned char const*, int, unsigned char*, int)' 
color_yuv.cpp:(.text._ZN2cv3hal19cvtTwoPlaneYUVtoBGREPKhjPhjiiibi+0x14c): `carotene_o4t::yuv420sp2bgr(carotene_o4t::Size2D const&, unsigned char const*, int, unsigned char const*, int, unsigned char*, int)' 
color_yuv.cpp:(.text._ZN2cv3hal19cvtTwoPlaneYUVtoBGREPKhjPhjiiibi+0x152): `carotene_o4t::yuv420sp2bgrx(carotene_o4t::Size2D const&, unsigned char const*, int, unsigned char const*, int, unsigned char*, int)' 
/home/atmark/opencv4-static/lib/libopencv_core.a(persistence.cpp.o): undefined reference to `cv::FileStorage::Impl::rewind()' :
persistence.cpp:(.text._ZN2cv11FileStorage4Impl6rewindEv[_ZN2cv11FileStorage4Impl6rewindEv]+0x1a): `gzrewind' 
/home/atmark/opencv4-static/lib/libopencv_core.a(persistence.cpp.o): undefined reference to `cv::FileStorage::Impl::closeFile()' :
persistence.cpp:(.text._ZN2cv11FileStorage4Impl9closeFileEv[_ZN2cv11FileStorage4Impl9closeFileEv]+0x24): `gzclose' 
/home/atmark/opencv4-static/lib/libopencv_core.a(persistence.cpp.o): undefined reference to `cv::FileStorage::Impl::eof()' :
persistence.cpp:(.text._ZN2cv11FileStorage4Impl3eofEv[_ZN2cv11FileStorage4Impl3eofEv]+0x38): `gzeof' 
/home/atmark/opencv4-static/lib/libopencv_core.a(persistence.cpp.o): undefined reference to `cv::FileStorage::Impl::puts(char const*)' :
persistence.cpp:(.text._ZN2cv11FileStorage4Impl4putsEPKc[_ZN2cv11FileStorage4Impl4putsEPKc]+0x6a): `gzputs' 
/home/atmark/opencv4-static/lib/libopencv_core.a(persistence.cpp.o): undefined reference to `cv::FileStorage::Impl::gets(char*, int)' :
persistence.cpp:(.text._ZN2cv11FileStorage4Impl4getsEPci[_ZN2cv11FileStorage4Impl4getsEPci]+0x128): `gzgets' 
/home/atmark/opencv4-static/lib/libopencv_core.a(persistence.cpp.o): undefined reference to `cv::FileStorage::Impl::gets()' :
persistence.cpp:(.text._ZN2cv11FileStorage4Impl4getsEv[_ZN2cv11FileStorage4Impl4getsEv]+0x104): `gzeof' 
/home/atmark/opencv4-static/lib/libopencv_core.a(persistence.cpp.o): undefined reference to `cv::FileStorage::Impl::release(std::string*) [clone .constprop.294]' :
persistence.cpp:(.text._ZN2cv11FileStorage4Impl7releaseEPSs.constprop.294+0x1e4): `gzclose' 
/home/atmark/opencv4-static/lib/libopencv_core.a(persistence.cpp.o): undefined reference to `cv::FileStorage::releaseAndGetString()' :
persistence.cpp:(.text._ZN2cv11FileStorage19releaseAndGetStringEv+0x25c): `gzclose' 
/home/atmark/opencv4-static/lib/libopencv_core.a(persistence.cpp.o): undefined reference to `cv::FileStorage::Impl::open(char const*, int, char const*)' :
persistence.cpp:(.text._ZN2cv11FileStorage4Impl4openEPKciS3_[_ZN2cv11FileStorage4Impl4openEPKciS3_]+0x69e): `gzopen' 
persistence.cpp:(.text._ZN2cv11FileStorage4Impl4openEPKciS3_[_ZN2cv11FileStorage4Impl4openEPKciS3_]+0x7d0): `gzrewind' 
collect2: error: ld returned 1 exit status

it looks like didn't link the 3rd libs.

I want a version of OpenCV libs with dependencies(libstd..) or complete static OpenCV libs.

Found something:

Looks like it's a BUG of pkg-config, pkg-config --static not worked. so the 3rd libs didn't link.

arm-linux-gnueabihf-g++-4.9 -std=c++11 videocapture_basic.cpp -o camera `pkg-config opencv4 --cflags --libs` -L/home/atmark/opencv4-static/lib/opencv4/3rdparty -lquirc -llibprotobuf -ltegra_hal -lzlib -llibjpeg-turbo -llibwebp -llibpng -llibtiff -llibjasper -lIlmImf -L/home/atmark/opencv-4.0.1/static-build/lib -lade -ldl -lm -lpthread -lrt

Now error remains only:

arm-linux-gnueabihf-g++-4.9 -std=c++11 videocapture_basic.cpp -o camera `pkg-config opencv4 --cflags --libs` -L/home/atmark/opencv4-static/lib/opencv4/3rdparty -lquirc -llibprotobuf -ltegra_hal -lzlib -llibjpeg-turbo -llibwebp -llibpng -llibtiff -llibjasper -lIlmImf -L/home/atmark/opencv-4.0.1/static-build/lib -lade -ldl -lm -lpthread -lrt 
/home/atmark/opencv4-static/lib/opencv4/3rdparty/libIlmImf.a(ImfZipCompressor.cpp.o): undefined reference to `Imf::ZipCompressor::compress(char const*, int, int, char const*&)' :
ImfZipCompressor.cpp:(.text._ZN3Imf13ZipCompressor8compressEPKciiRS2_+0xa0): `compress' 
/home/atmark/opencv4-static/lib/opencv4/3rdparty/libIlmImf.a(ImfZipCompressor.cpp.o): undefined reference to `Imf::ZipCompressor::uncompress(char const*, int, int, char const*&)' :
ImfZipCompressor.cpp:(.text._ZN3Imf13ZipCompressor10uncompressEPKciiRS2_+0x28): `uncompress' 
/home/atmark/opencv4-static/lib/opencv4/3rdparty/libIlmImf.a(ImfPxr24Compressor.cpp.o): undefined reference to `Imf::Pxr24Compressor::compress(char const*, int, Imath::Box<Imath::Vec2<int> >, char const*&) [clone .part.3]' :
ImfPxr24Compressor.cpp:(.text._ZN3Imf15Pxr24Compressor8compressEPKciN5Imath3BoxINS3_4Vec2IiEEEERS2_.part.3+0x17e): `compress' 
/home/atmark/opencv4-static/lib/opencv4/3rdparty/libIlmImf.a(ImfPxr24Compressor.cpp.o): undefined reference to `Imf::Pxr24Compressor::uncompress(char const*, int, Imath::Box<Imath::Vec2<int> >, char const*&) [clone .part.4]' :
ImfPxr24Compressor.cpp:(.text._ZN3Imf15Pxr24Compressor10uncompressEPKciN5Imath3BoxINS3_4Vec2IiEEEERS2_.part.4+0x28): `uncompress' 
collect2: error: ld returned 1 exit status
3
  • Why the "c" tag? Also, if a piece of software doesn't work as expected (including compiling it), you should write a bug report. If you want to discuss the problem itself here, you'd have to extract a minimal reproducible example first. Commented Apr 25, 2019 at 5:10
  • @UlrichEckhardt SO recommended "c" tag Commented Apr 25, 2019 at 5:15
  • It was just a recommendation which you don't have to follow. Be smart, make an informed decision. Commented Apr 25, 2019 at 5:19

1 Answer 1

3

Problem solved by disabling OpenEXR -DWITH_OPENEXR=OFF of OpenCV:

cmake -DCMAKE_TOOLCHAIN_FILE=../platforms/linux/arm-gnueabi.toolchain.cmake -DCMAKE_INSTALL_PREFIX=~/opencv4-static -DBUILD_SHARED_LIBS=OFF -DBUILD_WITH_STATIC_CRT=ON -DCMAKE_BUILD_TYPE=RELEASE -DOPENCV_GENERATE_PKGCONFIG=ON -DWITH_OPENEXR=OFF ../

And compile the application with static std libs:

arm-linux-gnueabihf-g++-4.9 -std=c++11 videocapture_basic.cpp -o camera `pkg-config opencv4 --cflags --libs` -L/home/atmark/opencv4-static/lib/opencv4/3rdparty -lquirc -llibprotobuf -ltegra_hal -lzlib -llibjpeg-turbo -llibwebp -llibpng -llibtiff -llibjasper -L/home/atmark/opencv-4.0.1/static-build/lib -lade -ldl -lm -lpthread -lrt -static -static-libgcc -static-libstdc++
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.