nekobean / mahjong-cpp

Miscellaneous programs about Japanese Mahjong
MIT License
101 stars 16 forks source link

error in using cmake #1

Closed KyL0N closed 2 years ago

KyL0N commented 2 years ago

i create a folder named build/ in mahjong-cpp/src/sample and i entered build/ using cmake .. error as followed

/mahjong-cpp/src/mahjong/types/hand.hpp:12:10: fatal error: 'mahjong/bitutils.hpp' file not found
#include "mahjong/bitutils.hpp"

and a change the include line in mahjong/bitutils.hpp into ../bitutils.hpp then error as follow

mahjong-cpp/src/mahjong/expectedvaluecalculator.cpp:658:27: error: no member named 'try_emplace' in 'std::map<mahjong::CacheKey, std::tuple<std::vector<double, std::allocator<double> >, std::vector<double, std::allocator<double> >, std::vector<double, std::allocator<double> > >, std::less<mahjong::CacheKey>, std::allocator<std::pair<const mahjong::CacheKey, std::tuple<std::vector<double, std::allocator<double> >, std::vector<double, std::allocator<double> >, std::vector<double, std::allocator<double> > > > > >'
    auto [itr, _] = table.try_emplace(key, tenpai_probs, win_probs, exp_values);

I don't know how to treat it :(

nekobean commented 2 years ago

Please create the build directory in the project root, not in src/sample, because setting include path and enabling C++17 support is done in the top CMakeLists.txt.

├── build <-- create here
├── CMakeLists.txt
├── LICENSE
├── README.md
├── data
└── src

If the build is successful, binaries will be generated in build/src/samples

ls -1 build/src/samples/
sample_calculate_expexted_value
sample_calculate_score
sample_calculate_syanten
sample_required_tile_selector
sample_unnecessary_tile_selector
KyL0N commented 2 years ago
>>> >  mahjong-cpp >  git:(master) mkdir build && cd build
>>> >  build >  git:(master) cmake ..
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- 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: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: system filesystem

it nolonger processed System: Ubuntu 20.04 LTS x86_64

and my enviroment is

>>> >  build >  git:(master) g++ --version
g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

>>> >  build >  git:(master) cmake --version
cmake version 3.16.3

>>> >  build >  git:(master) dpkg -s libboost-dev
Package: libboost-dev
Status: install ok installed
Priority: optional
Section: libdevel
Installed-Size: 10
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Multi-Arch: same
Source: boost-defaults
Version: 1.71.0.0ubuntu2
Depends: libboost1.71-dev
Suggests: libboost-doc
Description: Boost C++ Libraries development files (default version)
 The Boost web site provides free, peer-reviewed, portable C++ source
 libraries. The emphasis is on libraries which work well with the C++
 Standard Library. One goal is to establish "existing practice" and
 provide reference implementations so that the Boost libraries are
 suitable for eventual standardization. Some of the libraries have
 already been proposed for inclusion in the C++ Standards Committee's
 upcoming C++ Standard Library Technical Report.
 .
 This package provides headers for all Boost libraries.
 .
 Extended precision arithmetic package libmpfrc++-dev or libntl-dev is
 required to use the Boost.Multiprecision wrapping of the respective
 library.
 .
 This package is a dependency package, which depends on Debian's default
 Boost version (currently 1.71).
Homepage: https://www.boost.org/
Original-Maintainer: Debian Boost Team <team+boost@tracker.debian.org>
nekobean commented 2 years ago

GCC, Boost, and CMake versions seem to be fine.

Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: system filesystem

After the above message, CMake try to download the dependent Libraries (spdlog, rapidjson) using FetchContent module.

Waiting for a few minutes and the process doesn't proceed? In my environment, it takes a few seconds.

All CMake output

root@f6bcd75288ab:~# git clone https://github.com/nekobean/mahjong-cpp.git
Cloning into 'mahjong-cpp'...
remote: Enumerating objects: 2098, done.
remote: Counting objects: 100% (2098/2098), done.
remote: Compressing objects: 100% (995/995), done.
remote: Total 2098 (delta 1327), reused 1806 (delta 1037), pack-reused 0
Receiving objects: 100% (2098/2098), 87.24 MiB | 9.29 MiB/s, done.
Resolving deltas: 100% (1327/1327), done.
root@f6bcd75288ab:~# cd mahjong-cpp
root@f6bcd75288ab:~/mahjong-cpp# mkdir build && cd build
root@f6bcd75288ab:~/mahjong-cpp/build# cmake ..
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- 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: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: system filesystem
-- Build spdlog: 1.9.2
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Build type: Release
-- Configuring done
-- Generating done
-- Build files have been written to: /root/mahjong-cpp/build

Commands for the build

git clone https://github.com/nekobean/mahjong-cpp.git
cd mahjong-cpp
mkdir build && cd build
cmake ..
make -j$(nproc)
KyL0N commented 2 years ago

well

After the above message, CMake try to download the dependent Libraries (spdlog, rapidjson) using FetchContent module.

I think my server couldn't download it cuz GFW I will try it in proxy later :)

KyL0N commented 2 years ago

thanks! after I change the source uri in CMakeList.txt it done since few time