c++ - OpenCV cannot compile in custom directory -


i on ubuntu , want install different version of opencv(2.4.13) on custom directory. followed tutorial here: http://code.litomisky.com/2014/03/09/how-to-have-multiple-versions-of-the-same-library-side-by-side/

i cannot simple main.cpp program compile. cannot create cv::mat image, can obtain opencv version fine!:

#include <iostream> #include <opencv2/core/version.hpp> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp>  int main(int argc, char ** argv) { std::cout << "opencv version: "         << cv_major_version << "."          << cv_minor_version << "."         << cv_subminor_version         << std::endl;  cv::mat image; //without line, works!   return 0; } 

here makefile:

cpp = g++ -std=c++0x  # opencv 2.4.13 cppflags = -l/home/myname/desktop/myfolder/rewrite/opencv-2.4.13/release/installed/lib  \            -i/home/myname/desktop/myfolder/rewrite/opencv-2.4.13/release/installed/include   all: test  test: main.cpp      $(cpp) $(cppflags) $^ -o $@ 

this compiler error:

/tmp/ccyrdd7h.o: in function `cv::mat::~mat()': main.cpp:(.text._zn2cv3matd1ev[cv::mat::~mat()]+0x39): undefined reference `cv::fastfree(void*)' /tmp/ccyrdd7h.o: in function `cv::mat::release()': main.cpp:(.text._zn2cv3mat7releaseev[cv::mat::release()]+0x47): undefined reference `cv::mat::deallocate()' collect2: ld returned 1 exit status make: *** [test] error 1 

your makefile wrong. -l & -l options relevant @ link time (but not @ compile time). see this & that answers , examples (both quite similar question, , showing makefile should able adapt). run make -p understand builtin rules , variables used them.

(i guessing on linux)

read more elf, linkers & dynamic linkers, object files, executables, etc.. see levine's linkers , loaders book.

btw, cv_major_version etc... macro defined in header (mentioned of #include directives). cv::mat genuine c++ class, constructor or vtable referenced @ link time.

perhaps should read book c++, e.g. programming -- principles , practice using c++; don't have time , space explain here.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -