Building From Source Error
Dear authors,
We met an installing issue when building Openspiel from source. We first created an environment and then run the following commands in the Openspiel directory.
mkdir build cd build CC=/sw/arcts/centos7/gcc/9.2.0/bin/gcc CXX=/sw/arcts/centos7/gcc/9.2.0/bin/g++ cmake -DPython_TARGET_VERSION=3.6 -DCMAKE_CXX_COMPILER=/sw/arcts/centos7/gcc/9.2.0/bin/g++ ../open_spiel make
The version and position of gcc and g++ are specified (cmake/3.13.2 and gcc/9.2.0). We are working on CentOS. When we "make", we met the following error:
Scanning dependencies of target open_spiel_core [ 1%] Building CXX object CMakeFiles/open_spiel_core.dir/canonical_game_strings.cc.o [ 1%] Building CXX object CMakeFiles/open_spiel_core.dir/fog/observation_history.cc.o In file included from /home/wangyzh/open_spiel/open_spiel/fog/observation_history.cc:15: /home/wangyzh/open_spiel/open_spiel/../open_spiel/fog/observation_history.h:48:10: error: declaration of ‘open_spiel::Action open_spiel::ActionOrObs::Action() const’ changes meaning of ‘Action’ [-fpermissive] 48 | Action Action() const { | ^~~~~~ In file included from /home/wangyzh/open_spiel/open_spiel/../open_spiel/spiel_globals.h:18, from /home/wangyzh/open_spiel/open_spiel/../open_spiel/fog/observation_history.h:23, from /home/wangyzh/open_spiel/open_spiel/fog/observation_history.cc:15: /home/wangyzh/open_spiel/open_spiel/../open_spiel/spiel_utils.h:112:7: note: ‘Action’ declared here as ‘using Action = int64_t’ 112 | using Action = int64_t; | ^~~~~~ cc1plus: warning: unrecognized command line option ‘-Wno-everything’ make[2]: *** [CMakeFiles/open_spiel_core.dir/fog/observation_history.cc.o] Error 1 make[1]: *** [CMakeFiles/open_spiel_core.dir/all] Error 2 make: *** [all] Error 2
We skipped compiling the fog directory by removing fog files from CMakeLists.txt under the open_spiel directory. The "make" succeeded but we noticed that the pyspiel was not installed and tests files related to python packages were not run. So we were wondering how to fix this. Thank you so much!
Hi @wyz2368 , I am guessing that this is a g++ vs. clang++ thing.. or possibly that you need to add -std=c++17 ? Or maybe they have different default flags; e.g. you can probably disable this check somehow.
@michalsustr: you recently compiled with g++... can you check if observation_history compiles works under g++? Also, can we just rename these functions to GetAction and GetObservation to avoid this problem altogether?
Hi @wyz2368 I created a PR #303 that should fix this, you can merge it in the meantime before it gets into master (probably on Monday).
@lanctot Yeah I just renamed it. I started using clang++ recently, I didn't check in g++. I just thought -- maybe Travis could be set up to support both?
@lanctot Yeah I just renamed it. I started using clang++ recently, I didn't check in g++. I just thought -- maybe Travis could be set up to support both?
Sure, makes sense, would be good that we can get flagged when g++ fails. Feel free to add it!
Thanks @lanctot @michalsustr ! The compile issue was resolved. But the second issue still exists. That is, the pyspiel is not installed after "make". There is no error reported during "make". When I run "ctest" after "make", only 87 test cases are there in total. But when I try to build OpenSpiel from source on my Mac (running ./open_spiel/scripts/build_and_run_tests.sh with clang), there are 158 test cases in total. The missing test cases are all related to the /open_spiel/python (e.g., dqn_test is missing). I guess there might be something different between running build_and_run_tests.sh and manually "make" or the compiling script does not install everything under g++.
For example, after "make", import pyspiel would fail because package pyspiel does not exist. Same issue would appear when I manually run, for example, dqn_test.py.
According to the installing instruction, after compiling, we need to set Python path like
export PYTHONPATH=$PYTHONPATH:/<path_to_open_spiel> export PYTHONPATH=$PYTHONPATH:/<path_to_open_spiel>/build/python
However, I found that there is no /<path_to_open_spiel>/build/python in the build directory after "make". My python version is 3.6.5.
The build directory only contains
abseil-cpp CMakeCache.txt cmake_install.cmake examples game_transforms Testing utils algorithms CMakeFiles CTestTestfile.cmake games Makefile tests
Normally, it should contain
CMakeCache.txt Testing examples tests CMakeFiles abseil-cpp game_transforms utils CTestTestfile.cmake algorithms games Makefile cmake_install.cmake python
Hmm.. something is majorly wrong, I suggest you simply start over from scratch: rm -rf build venv then rerun everything from the start.
Possibly you have BUILD_WITH_PYTHON set to off somewhere in your environment. Maybe try adding BUILD_WITH_PYTHON=ON manually to the cmake command.
Thank you very much @lanctot ! Everything back to normal after adding BUILD_WITH_PYTHON=ON.
Another warning related to the g++ is
''' In file included from /home/wangyzh/open_spiel/open_spiel/python/pybind11/bots.cc:29: /home/wangyzh/open_spiel/open_spiel/../pybind11/include/pybind11/cast.h:398:31: warning: declaration of ‘bool pybind11::detail::isinstance_generic(pybind11::handle, const std::type_info&)’ with attribute ‘noinline’ follows inline declaration [-Wattributes] 398 | PYBIND11_NOINLINE inline bool isinstance_generic(handle obj, const std::type_info &tp) { | ^~~~~~~~~~~~~~~~~~ In file included from /home/wangyzh/open_spiel/open_spiel/../pybind11/include/pybind11/cast.h:13, from /home/wangyzh/open_spiel/open_spiel/python/pybind11/bots.cc:29: /home/wangyzh/open_spiel/open_spiel/../pybind11/include/pybind11/pytypes.h:26:13: note: previous declaration of ‘bool pybind11::detail::isinstance_generic(pybind11::handle, const std::type_info&)’ here 26 | inline bool isinstance_generic(handle obj, const std::type_info &tp); | ^~~~~~~~~~~~~~~~~~ In file included from /home/wangyzh/open_spiel/open_spiel/python/pybind11/bots.cc:29: /home/wangyzh/open_spiel/open_spiel/../pybind11/include/pybind11/cast.h:405:38: warning: declaration of ‘std::string pybind11::detail::error_string()’ with attribute ‘noinline’ follows inline declaration [-Wattributes] 405 | PYBIND11_NOINLINE inline std::string error_string() { | ^~~~~~~~~~~~ In file included from /home/wangyzh/open_spiel/open_spiel/../pybind11/include/pybind11/cast.h:13, from /home/wangyzh/open_spiel/open_spiel/python/pybind11/bots.cc:29: /home/wangyzh/open_spiel/open_spiel/../pybind11/include/pybind11/pytypes.h:283:20: note: previous declaration of ‘std::string pybind11::detail::error_string()’ here 283 | inline std::string error_string(); | ^~~~~~~~~~~~ cc1plus: warning: unrecognized command line option ‘-Wno-everything’
'''
But it does not lead to a failure. Anyway, thank you again @lanctot @michalsustr !
Hi @wyz2368 , no problem. Actually, I figured out why you ran into this problem: we accidentally disabled the Python build by default when you build without using build_and_run_tests.sh script because it is set when sourcing global_variables.sh.
This is a bug, so we'll fix it. It'll go get merged on the next update. After that you should not need to explicitly used BUILD_WITH_PYTHON. Thanks for reporting this.
Thanks for your help, very appreciated!