0
votes

I'm trying to compile an opencv file however highgui library seems to be not found

g++ -O2 -W -Wall -lhighgui tracking.cc -o tracking
/usr/bin/ld: cannot find -lhighgui
collect2: error: ld returned 1 exit status

Any idea how to fix this?

I tried

updatedb
ldconfig
g++ -O2 -W -Wall -L/usr/lib/libopencv_highgui.so tracking.cc -o tracking

but nothing seems to work..

EDIT: issuing a pkg-config --libs --cflags opencv returns:

-I/usr/local/include/opencv -I/usr/local/include  /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_ocl.so /usr/local/lib/libopencv_photo.so /usr/local/lib/libopencv_stitching.so /usr/local/lib/libopencv_superres.so /usr/local/lib/libopencv_ts.a /usr/local/lib/libopencv_video.so /usr/local/lib/libopencv_videostab.so -lrt -lpthread -lm -ldl

issuing a

g++ pkg-config --libs --cflags opencv -L/usr/local/lib/ tracking.cc -o tracking

returns

/tmp/ccrc3n9d.o: In function main': tracking.cc:(.text+0x53): undefined reference tocvCreateCameraCapture' tracking.cc:(.text+0x95): undefined reference to cvNamedWindow' tracking.cc:(.text+0xb1): undefined reference tocvMoveWindow' tracking.cc:(.text+0xc5): undefined reference to cvNamedWindow' tracking.cc:(.text+0xe1): undefined reference tocvMoveWindow' ......

No idea!

1
you pass folders with -L, not files. try: -L/usr/lib/ -lopencv_highgui (and have a look there, too. it might be /usr/local/lib/ instead) - berak
ok that was one of the many tries.. still no idea but starting to think it's not something in the compilation itself but some bug in opencv - dendini

1 Answers

0
votes

Ok found a solution, just drop my code inside the samples directory of opencv and called buildall.sh

On a separate note isntalling opencv is not suggested but instead linking manually each time is best.