cyanray / mirai-cpp

本项目为 mirai-api-http 的 C++ 封装,方便使用 C++ 开发基于 mirai-api-http 插件。
GNU Affero General Public License v3.0
148 stars 38 forks source link

mac版本编译失败 #49

Closed zmdyy0318 closed 3 years ago

zmdyy0318 commented 3 years ago

编译方式: cmake ./ && make 平台: macOS bigsur 日志 zmdyy0318@zmdyy0318deAir git % git clone https://github.com/cyanray/mirai-cpp.git Cloning into 'mirai-cpp'... remote: Enumerating objects: 277, done. remote: Counting objects: 100% (277/277), done. remote: Compressing objects: 100% (154/154), done. remote: Total 2157 (delta 175), reused 198 (delta 120), pack-reused 1880 Receiving objects: 100% (2157/2157), 3.17 MiB | 1.47 MiB/s, done. Resolving deltas: 100% (1523/1523), done. zmdyy0318@zmdyy0318deAir git % cd mirai-cpp zmdyy0318@zmdyy0318deAir mirai-cpp % mkdir build zmdyy0318@zmdyy0318deAir mirai-cpp % cd build zmdyy0318@zmdyy0318deAir build % cmake ../ -- The C compiler identification is AppleClang 12.0.0.12000032 -- The CXX compiler identification is AppleClang 12.0.0.12000032 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /Users/zmdyy0318/git/mirai-cpp/build zmdyy0318@zmdyy0318deAir build % make Scanning dependencies of target mirai-cpp [ 25%] Building CXX object CMakeFiles/mirai-cpp.dir/src/event_func.cpp.o In file included from /Users/zmdyy0318/git/mirai-cpp/src/event_func.cpp:1: In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/exception:81: In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cstdlib:85: In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/stdlib.h:100: In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/math.h:311: /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/type_traits:1547:38: error: implicit instantiation of undefined template 'std::1::hash' : public integral_constant<bool, __is_empty(_Tp)> {}; ^ /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/unordered_map:425:18: note: in instantiation of template class 'std::1::is_empty<std::1::hash >' requested here bool = is_empty<_Hash>::value && !libcpp_is_final<_Hash>::value> ^ /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/unordered_map:1760:13: note: in instantiation of default argument for 'unordered_map_hasher<Cyan::MiraiEvent, std::1::hash_value_type<Cyan::MiraiEvent, std::1::function<std::1::shared_ptr (std::__1::shared_ptr)> >, std::1::hash >' required here typedef unordered_map_hasher<key_type, __value_type, hasher> hasher; ^~~~~~~~~~~~~~ /Users/zmdyy0318/git/mirai-cpp/include/mirai/mirai_bot.hpp:392:71: note: in instantiation of template class 'std::1::unordered_multimap<Cyan::MiraiEvent, std::1::function<std::1::shared_ptr (std::1::shared_ptr)>, std::1::hash, std::1::equal_to, std::1::allocator<std::1::pair<const Cyan::MiraiEvent, std::1::function<std::1::shared_ptr (std::__1::shared_ptr)> > > >' requested here ...std::unordered_multimap<MiraiEvent, function<WeakEvent(WeakEvent)>> proc... ^ /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/type_traits:428:50: note: template is declared here template struct _LIBCPP_TEMPLATE_VIS hash; ^ 1 error generated. make[2]: [CMakeFiles/mirai-cpp.dir/src/event_func.cpp.o] Error 1 make[1]: [CMakeFiles/mirai-cpp.dir/all] Error 2 make: *** [all] Error 2 zmdyy0318@zmdyy0318deAir build %

zmdyy0318 commented 3 years ago

cmake 切换 c++ 到14编译通过

zmdyy0318 commented 3 years ago

http://www.cplusplus.com/forum/general/238538/ 这是解决方案,忘记贴了