maxruby / OpenCV.jl

The OpenCV (C++) interface for Julia
Other
104 stars 28 forks source link

Support loading of opencv flann and viz #24

Open maxruby opened 7 years ago

maxruby commented 7 years ago

Systems: OSX 10.12.3 and Linux Julia: 0.6.0-pre.alpha.49, master/eca966c

Description:

  1. Attempting to load libopencv_flann headers from /usr/local/include/opencv2/opencv.hpp results in error: cannot use typeid with -fno-rtti. This indicates that rtti is required to support flann.
  2. Trying to load libopencv_viz on Linux (but not OSX) appears to cause errors. This needs to be confirmed and debugged.
julia> using OpenCV
In file included from :1:
In file included from /usr/local/include/opencv2/opencv.hpp:62:
In file included from /usr/local/include/opencv2/flann.hpp:48:
In file included from /usr/local/include/opencv2/flann/flann_base.hpp:40:
In file included from /usr/local/include/opencv2/flann/params.h:33:
/usr/local/include/opencv2/flann/any.h:58:51: error: cannot use typeid with -fno-rtti
    virtual const std::type_info& type() { return typeid(T); }
                                                  ^
/usr/local/include/opencv2/flann/any.h:268:31: error: cannot use typeid with -fno-rtti
        if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast();
                              ^
/usr/local/include/opencv2/flann/any.h:277:31: error: cannot use typeid with -fno-rtti
        if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast();
                              ^
/usr/local/include/opencv2/flann/any.h:285:34: error: cannot use typeid with -fno-rtti
        return policy->type() == typeid(anyimpl::empty_any);
                                 ^
/usr/local/include/opencv2/flann/any.h:305:34: error: cannot use typeid with -fno-rtti
        return policy->type() == typeid(T);
                                 ^
WARNING: requiring "OpenCV" in module "Main" did not define a corresponding module.
asbisen commented 7 years ago

Just a few more pointers, I am experiencing same issue. Although (OSX Sierra) I am successfully able to load dylib libraries using Libdl.dlopen.

               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.0-pre.alpha.229 (2017-03-22 21:53 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit cc917b5 (0 days old master)
|__/                   |  x86_64-apple-darwin16.4.0

julia> Libdl.dlopen("/Users/abisen/opt/opencv3/lib/libopencv_flann.dylib", Libdl.RTLD_GLOBAL)
Ptr{Void} @0x00007f9030449230

julia> Libdl.dlopen("/Users/abisen/opt/opencv3/lib/libopencv_viz", Libdl.RTLD_GLOBAL)
Ptr{Void} @0x00007f90353714b0

julia> using OpenCV
In file included from :1:
In file included from /Users/abisen/opt/opencv3/include/opencv2/opencv.hpp:62:
In file included from /Users/abisen/opt/opencv3/include/opencv2/flann.hpp:48:
In file included from /Users/abisen/opt/opencv3/include/opencv2/flann/flann_base.hpp:40:
In file included from /Users/abisen/opt/opencv3/include/opencv2/flann/params.h:33:
/Users/abisen/opt/opencv3/include/opencv2/flann/any.h:58:51: error: cannot use typeid with -fno-rtti
    virtual const std::type_info& type() { return typeid(T); }
                                                  ^
/Users/abisen/opt/opencv3/include/opencv2/flann/any.h:268:31: error: cannot use typeid with -fno-rtti
        if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast();
                              ^
/Users/abisen/opt/opencv3/include/opencv2/flann/any.h:277:31: error: cannot use typeid with -fno-rtti
        if (policy->type() != typeid(T)) throw anyimpl::bad_any_cast();
                              ^
/Users/abisen/opt/opencv3/include/opencv2/flann/any.h:285:34: error: cannot use typeid with -fno-rtti
        return policy->type() == typeid(anyimpl::empty_any);
                                 ^
/Users/abisen/opt/opencv3/include/opencv2/flann/any.h:305:34: error: cannot use typeid with -fno-rtti
        return policy->type() == typeid(T);
                                 ^
WARNING: requiring "OpenCV" in module "Main" did not define a corresponding module.

My vtk was installed using Homebrew with the following parameters brew install vtk --c++11 --verbose

asbisen commented 7 years ago

I have identified the culprit that is causing the error. Although OpenCV_libs.jl#27 comments out the library. Corresponding #include in include/opencv2/opencv.hpp#61-63 also needs to be commented out.

That would at least allow the module to load without errors.

maxruby commented 7 years ago

Corresponding #include in include/opencv2/opencv.hpp#61-63 also needs to be commented out.

Thanks for your feedback. Indeed, this is what I currently recommend as a temporary solution. However, this is not a permanent solution and therefore the issue here has been filed to enable typeid with -fno-rtti