OS X 10.8.5下的Boost编译错误



我有一个问题,试图在Mac OS X 10.8.5下使用Boost库,版本1.34.1编译一个项目。我使用Xcode 4.6.3和随附的命令行工具。这一定是OS X特有的问题,因为该项目是在CentOS Linux下编译的。

我在这里问这个问题,希望有人在OS X开发中使用Boost,并且可能遇到类似的问题。

我在下面附上了编译器消息的摘录。我试着在谷歌上搜索这个错误,但似乎找不到令人满意的答案。请让我知道,如果你能想到的东西从你的头顶或,这是更有可能的,如果你需要更多的信息(例如,源代码摘录),能够帮助我。

非常感谢,

,

塞巴斯蒂安

g++ -DPARC -DCPPPA_EXPORT= -fPIC -fno-common -D__STDC_LIMIT_MACROS -g -fno-inline -Wpointer-arith -Wwrite-strings -Wno-deprecated -Wreturn-type -W -I/usr/local/include  -O2    -I../../src/include -I../../LexBase/src -I/include -I/usr/local/include/boost-1_34_1 -I/Users/sebastiansulger/projects/xle/dev/xfr/src/../../bgdb -Idb_client -I./ -I../include -Ifacts -Irules -Ichoices -Iterms -Imatches -Idriver -Iparser -Itriples -Iprolog -Idebug -Inew_parser -o terms/TermStorage.o  -c terms/TermStorage.cpp
In file included from terms/TermStorage.cpp:9:
In file included from terms/TermStorage.h:28:
In file included from ./Types.h:26:
In file included from /usr/local/include/boost-1_34_1/boost/functional/hash.hpp:10:
/usr/local/include/boost-1_34_1/boost/functional/hash/hash.hpp:487:20: error:
      call to 'hash_value' is ambiguous
            return hash_value(val);
                   ^~~~~~~~~~
/usr/include/c++/4.2.1/ext/hashtable.h:595:16: note: in instantiation of member
      function 'boost::hash<long long>::operator()' requested here
      { return _M_hash(__key) % __n; }
               ^
/usr/include/c++/4.2.1/ext/hashtable.h:587:16: note: in instantiation of member
      function '__gnu_cxx::hashtable<std::pair<const long long, unsigned int>,
      long long, boost::hash<long long>, std::_Select1st<std::pair<const long
      long, unsigned int> >, std::equal_to<long long>, std::allocator<unsigned
      int> >::_M_bkt_num_key' requested here
      { return _M_bkt_num_key(__key, _M_buckets.size()); }
               ^
/usr/include/c++/4.2.1/ext/hashtable.h:522:18: note: in instantiation of member
      function '__gnu_cxx::hashtable<std::pair<const long long, unsigned int>,
      long long, boost::hash<long long>, std::_Select1st<std::pair<const long
      long, unsigned int> >, std::equal_to<long long>, std::allocator<unsigned
      int> >::_M_bkt_num_key' requested here
        size_type __n = _M_bkt_num_key(__key);
                        ^
/usr/include/c++/4.2.1/ext/hash_map:219:22: note: in instantiation of member
      function '__gnu_cxx::hashtable<std::pair<const long long, unsigned int>,
      long long, boost::hash<long long>, std::_Select1st<std::pair<const long
      long, unsigned int> >, std::equal_to<long long>, std::allocator<unsigned
      int> >::find' requested here
      { return _M_ht.find(__key); }
                     ^
terms/TermStorage.h:97:46: note: in instantiation of member function
      '__gnu_cxx::hash_map<long long, unsigned int, boost::hash<long long>,
      std::equal_to<long long>, std::allocator<unsigned int> >::find' requested
      here
      TsHashMapIter iter = mParent->mHashMap.find(t);
                                             ^
terms/TermStorage.cpp:85:47: note: in instantiation of member function
      'powerset::xfr::TermHashStorage<long long>::hashInsert' requested here
  uint32_t index = (uint32_t) mIntTermStorage.hashInsert(intVal);
                                              ^
/usr/local/include/boost-1_34_1/boost/functional/hash/hash.hpp:105:24: note:
      candidate function
    inline std::size_t hash_value(int v)
                       ^
/usr/local/include/boost-1_34_1/boost/functional/hash/hash.hpp:110:24: note:
      candidate function
    inline std::size_t hash_value(unsigned int v)
                       ^
/usr/local/include/boost-1_34_1/boost/functional/hash/hash.hpp:115:24: note:
      candidate function
    inline std::size_t hash_value(long v)
                       ^
/usr/local/include/boost-1_34_1/boost/functional/hash/hash.hpp:120:24: note:
      candidate function
    inline std::size_t hash_value(unsigned long v)
                       ^
/usr/local/include/boost-1_34_1/boost/functional/hash/hash.hpp:229:24: note:
      candidate function
    inline std::size_t hash_value(float v)
                       ^
/usr/local/include/boost-1_34_1/boost/functional/hash/hash.hpp:234:24: note:
      candidate function
    inline std::size_t hash_value(double v)
                       ^
/usr/local/include/boost-1_34_1/boost/functional/hash/hash.hpp:239:24: note:
      candidate function
    inline std::size_t hash_value(long double v)
                       ^
1 error generated.
make[1]: *** [terms/TermStorage.o] Error 1
make: *** [build] Error 2
Sebastian-Sulgers-MacBook-Pro:dev sebastiansulger$ 

编辑:我注意到boost/functional/hash/hash.hpp包括以下内容:

#if defined(BOOST_HAS_LONG_LONG) && defined(_M_X64) && defined(_WIN64)
    // On 64-bit windows std::size_t is a typedef for unsigned long long, which
    // isn't due to be supported until Boost 1.35. So add support here.
    // (Technically, Boost.Hash isn't actually documented as supporting
    // std::size_t. But it would be pretty silly not to).
    std::size_t hash_value(long long);
    std::size_t hash_value(unsigned long long);
#endif

所以似乎类型的定义是存在的,但在我的系统中不可用。这说得通吗?我能绕过这个吗?

它基本上说在hash.hpp中有很多hash_value函数,但它们都不适用于哈希表中的类型(显然是long long)。

您的工具对于该类型来说太旧了,或者您没有为编译器使用适当的-std=...参数进行编译。

最新更新