static linking of opencv is giving too much errors

Moderators: mdrjr, odroid

static linking of opencv is giving too much errors

Unread postby Indranil Sarkar » Thu Sep 06, 2018 5:20 pm

for make & make install of opencv 3.4.2 requires around of 6.9 GB and more. Previously in my same odroid I have run openv programs with dynamic linking & it worked. I thought of making it a static library, so that I can run my code with just the required static libs like libopencv_highgui.a libopencv_imgproc.a libopencv_core.a and since the rest dependencies are not so enormous in size so i can link them dynamically , like -lpthread, -lrt, -ldl or -lz, so that I can run my code on 8 gb ssd also(required).

I have successfully installed opencv statically by configuring BUILD_SHARED_LIBS=OFF. Again when i tried compiling my code there is not a bit problem, but when the linking stage comes it gives me 949 errors; Below is my code

Code: Select all
#include <opencv2/opencv.hpp>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
//#include <string>
#include <iostream>
//#include <cstdlib>
//#include <stdio.h>
using namespace std;
int main()
{
        cout<< "enter the limit";
        int limit;
        cin>>limit;
 
        cv::Mat m= cv::imread("/home/odroid/Pictures/spider_man_1280x720.jpg"); //input image
        cv::imshow("input grey scale", m);
 
        cv::Ptr<cv::CLAHE> clahe = cv::createCLAHE();
        clahe->setClipLimit(limit);
 
        cv::Mat dst;
        clahe->apply(m, dst);
        cv::imshow("CLAHE output ",dst);
 
        cv::waitKey();
}


odroid@odroid:~/Desktop/is2/@_opencl/static/s.0.1.0/s.0.1.0/main$ g++ --static main.cpp -I/usr/local/include/opencv2 -L /home/odroid/Desktop/is2/opencv/build/lib -lopencv_imgcodecs -lopencv_highgui -lopencv_imgproc -lopencv_core -ljpeg -lpng -ltiff -lrt -ldl -lz -lpthread -o myprog &> static_op.txt
contents of static_op.txt https://pastebin.com/DPKhtyww
anyone help would be strongly appreciated !!!
TIA
Indranil Sarkar
 
Posts: 38
Joined: Tue Apr 24, 2018 1:14 pm
languages_spoken: english
ODROIDs: ODROID-XU4

Re: static linking of opencv is giving too much errors

Unread postby tobetter » Thu Sep 06, 2018 7:19 pm

I guess you would add -Wl,-Bdynamic ahead of dynamic libraries in gcc command like this.
-Wl,-Bdynamic lopencv_imgcodecs -lopencv_highgui -lopencv_imgproc -lopencv_core -ljpeg -lpng -ltiff -lrt -ldl -lz -lpthread
tobetter
 
Posts: 2373
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: static linking of opencv is giving too much errors

Unread postby Indranil Sarkar » Thu Sep 06, 2018 9:06 pm

but lopencv_imgcodecs -lopencv_highgui -lopencv_imgproc -lopencv_core are static libraries, everything other than opencvlib are dynamic libraries .
like it should be-
-lopencv_imgcodecs -lopencv_highgui -lopencv_imgproc -lopencv_core -Wl,-Bdynamic ljpeg, -Wl,-Bdynamic lpng, -Wl,-Bdynamic ltiff, . . .
Indranil Sarkar
 
Posts: 38
Joined: Tue Apr 24, 2018 1:14 pm
languages_spoken: english
ODROIDs: ODROID-XU4


Return to Ubuntu

Who is online

Users browsing this forum: freefall99 and 3 guests