I am trying to run a opencv based simple rgb to gray scale script and run it through cuda. The header for the C++ script that does the computation links the following api from opencv
:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
I am trying to compile it using the following makefile
logic:
OPENCV_LIBPATH=-L/apps/gcc/4.7.2/opencv/2.4.8/lib
OPENCV_LIBPATH += -l/opt/cuda/5.5/lib64
OPENCV_INCLUDEPATH=/apps/gcc/4.7.2/opencv/2.4.8/include
OPENCV_LIBS=-lopencv_core -lopencv_imgproc -lopencv_highgui -lnppi -lz
CUDA_INCLUDEPATH=/opt/cuda/5.5/include
NVCC_OPTS=-O3 -arch=sm_20 -Xcompiler -Wall -Xcompiler -Wextra -m64
GCC_OPTS=-O3 -Wall -Wextra -m64
main: rgbtogrey.o rgb_to_grey.o Makefile
$(NVCC) -o main.out rgbtogrey.o rgb_to_grey.o -I$(OPENCV_INCLUDEPATH) $(OPENCV_LIBPATH) $(OPENCV_LIBS)
rgbtogrey.o: rgbtogrey.cpp timer.h utils.h
g++ -c rgbtogrey.cpp $(GCC_OPTS) -I $(CUDA_INCLUDEPATH) -I $(OPENCV_INCLUDEPATH)
rgb_to_grey.o: rgb_to_grey.cu utils.h
nvcc -c rgb_to_grey.cu $(NVCC_OPTS)
clean:
rm -f *.o hw
I tried a number of other solutions such as those outlined in Compiling a basic opencv cuda and Linking Cuda in C++ issue.
Current Error:
/apps/gcc/4.7.2/opencv/2.4.8/lib/libopencv_highgui.a(grfmt_exr.cpp.o): In function `cv::ExrDecoder::ExrDecoder()':
grfmt_exr.cpp:(.text._ZN2cv10ExrDecoderC2Ev+0x9d): undefined reference to `Imf::Chromaticities::Chromaticities(Imath::Vec2<float> const&, Imath::Vec2<float> const&, Imath::Vec2<float> const&, Imath::Vec2<float> const&)'
I am pretty new to this as such am not sure where to look for to solve this error.
EDIT:
1. Following the comment I added the lnppi
option to the main after adding the LIB path (see makefile portion updated)
Error now:
/apps/gcc/4.7.2/opencv/2.4.8/lib/libopencv_core.a(persistence.cpp.o): In function `icvGets(CvFileStorage
persistence.cpp:(.text._ZL7icvGetsP13CvFileStoragePci+0x127): undefined reference to `gzgets'
lz
Try to use the attached libraries under the OpenCV's OPENCV_PATH/3rdparty/lib
folder by -libIlmImf -llibjpeg -llibjasper -llibpng -lzlib
.
Also take care to the order in which libraries are linked, because any static library must be linked in the appropriate order otherwise unresolved references will appear with GNU ld:
If any [static] library A depends on symbols defined in library B, then library A should appear first in the list supplied to the linker.
See linker order - GCC for more information.