Sebastian Sulger
Sebastian Sulger

Reputation: 101

Boost compilation error under OS X 10.8.5

I have an issue trying to compile a project under Mac OS X 10.8.5 using Boost libraries, version 1.34.1. I am using Xcode 4.6.3 and accompanying Command Line Tools. This must be an OS X specific issue, since the project compiles under CentOS Linux.

I am asking this here in hopes that someone has used Boost in OS X development and has maybe come across a similar issue.

I attach an excerpt of the compiler messages below. I have tried googling for the error, but can't seem to find satisfying answers. Please let me know if you can think of something from the top of your head or, which is more likely, if you need more info (e.g., source code excerpts) to be able to help me.

Thank you very much,

Best,

Sebastian

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$ 

EDIT: I have noticed that boost/functional/hash/hash.hpp includes the following:

#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

So it seems that the definition of the type is there, but not available for my system. Does that make any sense? Can I circumvent this somehow?

Upvotes: 0

Views: 371

Answers (1)

Bo Persson
Bo Persson

Reputation: 92201

It basically says that there are lots of hash_value functions in hash.hpp, but none of them works for the type in your hash table (apparently long long).

Either your tools are too old for that type, or you don't compile with the proper -std=... parameter for the compiler.

Upvotes: 1

Related Questions