Ask Your Question
0

Static building undefined reference in Linux

asked 2013-02-23 01:47:09 -0600

lokoArt gravatar image

updated 2013-02-23 04:51:41 -0600

Hello. I built Opencv in Windows/Mac os as static library. It was easy. But in Linux I can't do it! How I build library: 1) Run graphic CMake and uncheck all modules except Core/ImgProc/Gighgui. Also Unchecked shared_library. 2) Do make and make install

In my .pro file in Qt creator there're lines like this there:

LIBS += -L/usr/local/lib/ \
 -lopencv_core \
 -lopencv_imgproc  \
 -lopencv_highgui \
 -llibjpeg \
 -lpng

And as I see it's being used at compliling:

g++ ... -L/usr/local/lib/ -lopencv_core -lopencv_imgproc -lopencv_highgui -llibjpeg -lpng ...

But i got errors like this:

 imgwarp.cpp:-1: error: undefined reference to `cv::ParallelLoopBody::~ParallelLoopBody()' color.cpp:-1: error: undefined reference to `cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double)'

There're errors inside Img proc library. What's wrong?

UPD: I checked building as shared library and everything's ok. There's problem only with static build

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-02-23 06:00:16 -0600

ParallelLoopBody class is a part of core module in OpenCV. On Linux library order in linking time is important, because one-pass linker is used. You need to reorder OpenCV libs and try again.

edit flag offensive delete link more

Comments

Oh... Thank you... I didn't know. I'm new in Linux developing and in Linux at all)

lokoArt gravatar imagelokoArt ( 2013-02-24 00:00:23 -0600 )edit

It's necesary to reorder OpenCV libs, but what is the correct order to successfully compile using it as static libs? ... libs/opencv/lib/libopencv_imgproc.a(color.cpp.o): In function cv::CvtColorLoop_Invoker<cv::RGB2RGB<unsigned char> >::~CvtColorLoop_Invoker()': color.cpp:(.text._ZN2cv20CvtColorLoop_InvokerINS_7RGB2RGBIhEEED2Ev[_ZN2cv20CvtColorLoop_InvokerINS_7RGB2RGBIhEEED5Ev]+0xf): undefined reference tocv::ParallelLoopBody::~ParallelLoopBody()' ...

I appreciate your help

osval gravatar imageosval ( 2015-01-24 15:54:29 -0600 )edit

Question Tools

Stats

Asked: 2013-02-23 01:47:09 -0600

Seen: 2,149 times

Last updated: Feb 23 '13