Chitika

Thursday, October 20, 2011

OpenCV application on linux make and execute

After building openCV, copy OpenCV-2.3.1/include and OpenCV-2.3.1/lib to build directory.
find all the files in lib directory and add it to makefile
find all the files:>ls lib/*so
copy the result and paste in makefile, create make file as follows:

makefile:
LIBS=lib/libopencv_calib3d.so     lib/libopencv_flann.so    lib/libopencv_legacy.so     lib/libopencv_video.so lib/libopencv_contrib.so     lib/libopencv_gpu.so      lib/libopencv_ml.so lib/libopencv_core.so        lib/libopencv_highgui.so  lib/libopencv_objdetect.so lib/libopencv_features2d.so  lib/libopencv_imgproc.so  lib/libopencv_ts.so

all: main
main:   main.cpp
        $(CPP) main.cpp -o main -I include/opencv $(LIBS)
        #$(CPP) --static -I -o main main.cpp $(LIBS) -lpthread -lrt -ltiff

clean:
        rm main

to build, execute >make
to run, execute >./main

*when I run, I get error of opencv dynamically linked library not found, by default OpenCV copy the library files in /usr/local/lib, copy files from /usr/local/lib to /usr/lib, then it will run fine.

as root, execute >cp /usr/local/lib/*so /usr/lib

No comments:

Post a Comment