efficient / libcuckoo

A high-performance, concurrent hash table
Other
1.62k stars 275 forks source link

Building problem with libcuckoo in Visual Studio 2019 version 16.2.4 #117

Closed DJuego closed 5 years ago

DJuego commented 5 years ago

Hi!! Thank you, again, for libcuckoo!

I'm trying to build for the first time in Visual Studio 2019. I'm using the same options as in Visual Studio 2017.

I get:

Compilacion libcuckoo

-- The C compiler identification is MSVC 19.22.27905.0
-- The CXX compiler identification is MSVC 19.22.27905.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: P:/Compilados/x32-x64/TRABAJO_MSVC2019_x64/libcuckoo/builds/debug

Microsoft (R) Program Maintenance Utility Version 14.22.27905.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Scanning dependencies of target nested_table
[  8%] Building CXX object examples/CMakeFiles/nested_table.dir/nested_table.cc.obj
nested_table.cc
[ 16%] Linking CXX executable nested_table.exe
[ 16%] Built target nested_table
Scanning dependencies of target int_str_table
[ 25%] Building CXX object examples/CMakeFiles/int_str_table.dir/int_str_table.cc.obj
int_str_table.cc
P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\libcuckoo\libcuckoo/cuckoohash_map.hh(429): error C2039: 'to_string': is not a member of 'std'
P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\libcuckoo\libcuckoo/cuckoohash_map.hh(2734): note: see declaration of 'std'
P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\libcuckoo\libcuckoo/cuckoohash_map.hh(427): note: while compiling class template member function 'void cuckoohash_map<int,const char *,std::hash<int>,std::equal_to<Key>,std::allocator<std::pair<const Key,T>>,4>::maximum_hashpower(unsigned __int64)'
        with
        [
            Key=int,
            T=const char *
        ]
P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\libcuckoo\libcuckoo-c/cuckoo_table_template.cc(48): note: see reference to function template instantiation 'void cuckoohash_map<int,const char *,std::hash<int>,std::equal_to<Key>,std::allocator<std::pair<const Key,T>>,4>::maximum_hashpower(unsigned __int64)' being compiled
        with
        [
            Key=int,
            T=const char *
        ]
P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\libcuckoo\libcuckoo-c/cuckoo_table_template.cc(29): note: see reference to class template instantiation 'cuckoohash_map<int,const char *,std::hash<int>,std::equal_to<Key>,std::allocator<std::pair<const Key,T>>,4>' being compiled
        with
        [
            Key=int,
            T=const char *
        ]
P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\libcuckoo\libcuckoo/cuckoohash_map.hh(429): error C3861: 'to_string': identifier not found
P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\libcuckoo\libcuckoo/cuckoohash_map.hh(429): error C2512: 'std::invalid_argument': no appropriate default constructor available
P:\Compilados\x32-x64\TRABAJO_MSVC2019_x64\libcuckoo\libcuckoo/cuckoohash_map.hh(430): note: No constructor could take the source type, or constructor overload resolution was ambiguous
NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~2\2019\ENTERP~1\VC\Tools\MSVC\1422~1.279\bin\Hostx64\x64\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.22.27905\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.22.27905\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.

DJuego

toojays commented 5 years ago

Any chance the fix is as simple as adding #include <string> to the top of cuckoohash_map.hh? We should have that for std::to_string(), but until now (with GCC at least) we get <string> indirectly via <stdexcept>. Perhaps MSVC 2019 requires us to be more explicit here.

DJuego commented 5 years ago

Indeed! I confirm that I have tried this solution successfully. Thank you, @toojays. I hope there will soon be an official bugfix in the master branch.

DJuego

manugoyal commented 5 years ago

Thanks for the find! I added #include <string> in 4f54e63b42b20a0834bded0feb876a2fd1fdba17. Hopefully that resolves the compile issue on MSVC, but I haven't tried it out myself.