Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Ok, finally the error was two fold in order to compile for the old OpenCV functions.

First, the problem is the use of old headers, so I changed the #include <opencv/cv.h> and use

#include <opencv2/legacy/legacy.hpp>
#include "opencv2/legacy/compat.hpp"

in my header files that included old headers.

Then, the makefile was wrong. It seems that to compile and link the linking libraries can only be in the last parameters of the call.

That is, g++ <flags> -o <target> <sources> <libs>, after fixing that order the files compile. I made a newer makefile, just in case someone stumble upon the same or similar problem.

CC=g++
CFLAGS=-Wall $(shell pkg-config --cflags opencv)
LDLIBS=$(shell pkg-config --libs opencv) 

all: main

# the main program, it uses the .o objects to rebuild
main: main.o global.o IntImage.h util.o mdarray.h
    $(CC) $(CFLAGS) -o main main.o global.o util.o $(LDLIBS)

# a target for all the objects
# it doesn't link (-c option)
%.o: %.cpp
    $(CC) $(CFLAGS) -c -o $@ $<

clean:
    rm -rf *.o main