Ask Your Question
0

How do I use opencv.pc 2.4.1

asked 2012-11-16 10:16:45 -0600

macropanther gravatar image

updated 2012-11-16 12:25:41 -0600

Normally I would know to use

pkg-config --libs opencv

as part of my linker command (ok, properties in NetBeans). However, I can't seem to get it to work.

The symptom of it not working is a laundry list of link-time errors that looks like:

/usr/local/include/opencv2/core/core_c.h:134: undefined reference to `cvFree_'
/usr/local/include/opencv2/core/core_c.h:142: undefined reference to `cvFree_'
build/Debug/GNU-Linux-x86/_ext/602031749/usingOpenCV.o: In function `cvGetRow':
/usr/local/include/opencv2/core/core_c.h:184: undefined reference to `cvGetRows'
build/Debug/GNU-Linux-x86/_ext/602031749/usingOpenCV.o: In function `cvGetCol':
/usr/local/include/opencv2/core/core_c.h:195: undefined reference to `cvGetCols'

From what I read the opencv.pc file produced when i built opencv following these instructions, is broken or non-standard.


  1. *Is this correct? Is there a fix/patch? With instructions on how to apply it? *
  2. Does anyone have an opencv.pc file that returns the usual -l nad -L type entries rather than the list of .so's.
  3. Are there other tags i should add to this question? I am not familiar enogh with opencv to know which to select for it.

Example:

$ pkg-config --libs opencv
/usr/local/lib/libopencv_calib3d.so /usr/local/lib/libopencv_contrib.so /usr/local
/lib/libopencv_core.so /usr/local/lib/libopencv_features2d.so /usr/local
/lib/libopencv_flann.so /usr/local/lib/libopencv_gpu.so /usr/local/lib/libopencv_highgui.so 
/usr/local/lib/libopencv_imgproc.so /usr/local/lib/libopencv_legacy.so 
/usr/local/lib/libopencv_ml.so /usr/local/lib/libopencv_nonfree.so 
/usr/local/lib/libopencv_objdetect.so /usr/local/lib/libopencv_photo.so 
/usr/local/lib/libopencv_stitching.so /usr/local/lib/libopencv_ts.so 
/usr/local/lib/libopencv_video.so /usr/local/lib/libopencv_videostab.so

I was really expecting something that looked like -L/usr/local/lib -lopencv-core ....

I tried coding the -l's by hand in my NetBeans linker command, but that fails also. :-(

-o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/autostart -L/opt/voyant/lib -L/usr/local/lib  
-lvoyant -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu 
-lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree 
-lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_ts -lopencv_video
-lopencv_videostab `pkg-config --libs opencv`

and I tried both gcc and g++. Same errors, different progress messages.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2012-12-17 06:24:11 -0600

macropanther gravatar image

I finally found th eanswer to this problem. Has nothing to do with open/cv. There is a reguirement that the list of ".o" files (inputs) and the output file (-o whatever) appear before any -L's or -l's in the command line of some versions of gcc/g++. In eclipse this means putting the ${flags} variable in the command template LAST instead of second and it means getting all the libraries properly identified, including pkg-config libraries, in the properties for the project.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-11-16 10:16:45 -0600

Seen: 2,324 times

Last updated: Dec 17 '12