Compiler errors on Mac Lion 10.7.3

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Compiler errors on Mac Lion 10.7.3

xproj1999
I'm trying to compile opencv2 as in the wiki. But I see this errors when i launch MAKE:


Scanning dependencies of target opencv_flann
[ 22%] Building CXX object modules/flann/CMakeFiles/opencv_flann.dir/src/flann.o
In file included from /Users/salvo/Documents/Sviluppo/opencv2/OpenCV-2.3.1/modules/flann/src/flann.cpp:29:
In file included from /Users/salvo/Documents/Sviluppo/opencv2/OpenCV-2.3.1/modules/flann/src/precomp.hpp:17:
In file included from /Users/salvo/Documents/Sviluppo/opencv2/OpenCV-2.3.1/modules/flann/include/opencv2/flann/all_indices.h:42:
/Users/salvo/Documents/Sviluppo/opencv2/OpenCV-2.3.1/modules/flann/include/opencv2/flann/lsh_index.h:89:81: error:
      no matching constructor for initialization of 'cvflann::LshIndexParams'
  ...input_data, const IndexParams& params = LshIndexParams(),
                                             ^
/Users/salvo/Documents/Sviluppo/opencv2/OpenCV-2.3.1/modules/flann/include/opencv2/flann/lsh_index.h:59:5: note:
      candidate constructor not viable: requires 3 arguments, but 0 were
      provided
    LshIndexParams(unsigned int table_number, unsigned int key_size, ...
    ^
/Users/salvo/Documents/Sviluppo/opencv2/OpenCV-2.3.1/modules/flann/include/opencv2/flann/lsh_index.h:57:8: note:
      candidate constructor (the implicit copy constructor) not viable: requires
      1 argument, but 0 were provided
struct LshIndexParams : public IndexParams
       ^
In file included from /Users/salvo/Documents/Sviluppo/opencv2/OpenCV-2.3.1/modules/flann/src/flann.cpp:29:
In file included from /Users/salvo/Documents/Sviluppo/opencv2/OpenCV-2.3.1/modules/flann/src/precomp.hpp:10:
In file included from /Users/salvo/Documents/Sviluppo/opencv2/OpenCV-2.3.1/modules/flann/include/opencv2/flann/index_testing.h:39:
In file included from /Users/salvo/Documents/Sviluppo/opencv2/OpenCV-2.3.1/modules/flann/include/opencv2/flann/nn_index.h:39:
In file included from /Users/salvo/Documents/Sviluppo/opencv2/OpenCV-2.3.1/modules/flann/include/opencv2/flann/params.h:33:
/Users/salvo/Documents/Sviluppo/opencv2/OpenCV-2.3.1/modules/flann/include/opencv2/flann/any.h:88:67: error:
      call to function 'operator<<' that is neither visible in the template
      definition nor found by argument-dependent lookup
    virtual void print(std::ostream& out, void* const* src) { out << ...
                                                                  ^
/Users/salvo/Documents/Sviluppo/opencv2/OpenCV-2.3.1/modules/flann/include/opencv2/flann/any.h:136:44: note:
      in instantiation of member function
      'cdiggins::anyimpl::big_any_policy<cdiggins::anyimpl::empty_any>::print'
      requested here
    static typename choose_policy<T>::type policy;
                                           ^
/Users/salvo/Documents/Sviluppo/opencv2/OpenCV-2.3.1/modules/flann/include/opencv2/flann/any.h:159:18: note:
      in instantiation of function template specialization
      'cdiggins::anyimpl::get_policy<cdiggins::anyimpl::empty_any>' requested
      here
        : policy(anyimpl::get_policy<anyimpl::empty_any>()), object(NULL)
                 ^
/Users/salvo/Documents/Sviluppo/opencv2/OpenCV-2.3.1/modules/flann/include/opencv2/flann/any.h:276:22: note:
      'operator<<' should be declared prior to the call site or in namespace
      'cdiggins::anyimpl'
inline std::ostream& operator <<(std::ostream& out, const any& any_val)
                     ^
2 errors generated.
make[2]: *** [modules/flann/CMakeFiles/opencv_flann.dir/src/flann.o] Error 1
make[1]: *** [modules/flann/CMakeFiles/opencv_flann.dir/all] Error 2
make: *** [all] Error 2


why?

Reply | Threaded
Open this post in threaded view
|

Re: Compiler errors on Mac Lion 10.7.3

Evade Flow
This post has NOT been accepted by the mailing list yet.
OS X Lion's compiler is stricter about certain C++ constructs than previous versions, which prevents OpenCV-2.3.1 from compiling cleanly. The patch below should fix things up for you:
diff --git a/modules/flann/include/opencv2/flann/any.h b/modules/flann/include/opencv2/flann/any.h
index 46e1116..06db1b2 100644
--- a/modules/flann/include/opencv2/flann/any.h
+++ b/modules/flann/include/opencv2/flann/any.h
@@ -30,6 +30,12 @@ struct empty_any
 {
 };
 
+inline std::ostream& operator <<(std::ostream& out, const empty_any&)
+{
+    out << "[empty_any]";
+    return out;
+}
+
 struct base_any_policy
 {
     virtual void static_delete(void** x) = 0;
diff --git a/modules/flann/include/opencv2/flann/lsh_index.h b/modules/flann/include/opencv2/flann/lsh_index.h
index a777990..6ed5740 100644
--- a/modules/flann/include/opencv2/flann/lsh_index.h
+++ b/modules/flann/include/opencv2/flann/lsh_index.h
@@ -56,7 +56,7 @@ namespace cvflann
 
 struct LshIndexParams : public IndexParams
 {
-    LshIndexParams(unsigned int table_number, unsigned int key_size, unsigned int multi_probe_level)
+    LshIndexParams(unsigned int table_number = 12, unsigned int key_size = 20, unsigned int multi_probe_level = 2)
     {
         (* this)["algorithm"] = FLANN_INDEX_LSH;
         // The number of hash tables to use