Closed BorisMuller closed 1 year ago
Hi,
Seems like you are missing the dependencies.
You still need to run ./install.sh
from the installation instructions before building.
Hi,
Seems like you are missing the dependencies.
You still need to run
./install.sh
from the installation instructions before building.
Solved!
I did run into another error later on that I managed to solve with the help of Bing Chat. When running the following command: cd ../open_spiel/examples clang++ -I${HOME}/open_spiel -I${HOME}/open_spiel/open_spiel/abseil-cpp -L${HOME}/open_spiel/build -lopen_spiel -std=c++17 -o shared_library_example shared_library_example.cc
I ran into the following error:
/usr/bin/ld: /tmp/ccBICDuM.o: in function main': shared_library_example.cc:(.text+0x232): undefined reference to
open_spiel::RegisteredGames[abi:cxx11]()'
/usr/bin/ld: shared_library_example.cc:(.text+0x374): undefined reference to open_spiel::LoadGame(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' /usr/bin/ld: shared_library_example.cc:(.text+0x5d4): undefined reference to
open_spiel::SampleAction(std::vector<std::pair<long, double>, std::allocator<std::pair<long, double> > > const&, absl::lts_20211102::BitGenRef)'
/usr/bin/ld: shared_library_example.cc:(.text+0x919): undefined reference to `open_spiel::State::ApplyActions(std::vector<long, std::allocator
Bing chat told me the -lopen_spiel option should be specified after the object files or source files to ensure that the linker can find the definitions for the functions used in your code. After running the updated command: g++ -I${HOME}/open_spiel -I${HOME}/open_spiel/open_spiel/abseil-cpp -std=c++17 -o shared_library_example shared_library_example.cc -L${HOME}/open_spiel/build -lopen_spiel The code worked and I was succesfully able to run the example. Please do note that I used g++ instead of clang++. Do you think you could include running the install.sh step and this updated command in the https://openspiel.readthedocs.io/en/latest/library.html page?
Ok, great. The -lopen_spiel
was already in the compilation command on the page here: https://github.com/deepmind/open_spiel/blob/master/docs/library.md#compiling-and-running-the-example
Sure, we will add a mention of installing the dependencies. Thanks!
The -lopen_spiel is indeed mentioned but I ran into an error when it is in the middle of the command, when moving it to the end of the command it did work. This might be because I am using g++ instead, I am not sure.
Ah, yes, it seems like it is related to g++/gcc: https://stackoverflow.com/questions/3363398/g-linking-order-dependency-when-linking-c-code-to-c-code
I had forgotten about that. So I've re-ordered the order in the example to match yours.
When following the steps for compiling OpenSpiel as a Shared Library the following command fails: BUILD_SHARED_LIB=ON CXX=clang++ cmake -DPython3_EXECUTABLE=$(which python3) -DCMAKE_CXX_COMPILER=${CXX} ../open_spiel The following errors are reported: CMake Error at CMakeLists.txt:199 (add_subdirectory): add_subdirectory given source "abseil-cpp" which is not an existing directory.
Not building wheel. Finding Python normally... -- Could NOT find Python3 (missing: Development Development.Module Development.Embed) (found version "3.10.9") Python executable: /home/boris/miniconda3/envs/Othello/bin/python3 Python include dirs: /home/boris/anaconda3/include/python3.9 Python library dirs: /home/boris/anaconda3/lib OPEN_SPIEL_ENABLE_JAX set to AUTO. Detecting Jax... Not found. Enable printing errors in python/CMakeLists.txt to see output. OPEN_SPIEL_ENABLE_PYTORCH set to AUTO. Detecting PyTorch... Not found. Enable printing errors in python/CMakeLists.txt to see output. OPEN_SPIEL_ENABLE_TENSORFLOW set to AUTO. Detecting Tensorflow... Not found. Enable printing errors in python/CMakeLists.txt to see output. -- Configuring incomplete, errors occurred! See also "/home/boris/Downloads/open_spiel-1.2/build/CMakeFiles/CMakeOutput.log". See also "/home/boris/Downloads/open_spiel-1.2/build/CMakeFiles/CMakeError.log". You have changed variables that require your cache to be deleted. Configure will be re-run and you may have to reset some variables. The following variables have changed: CMAKE_CXX_COMPILER=
CMake Error at games/CMakeLists.txt:201 (add_library): Cannot find source file:
Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc
CMake Error at games/CMakeLists.txt:201 (add_library): No SOURCES given to target: bridge_double_dummy_solver
For some weird reason neither "/home/boris/Downloads/open_spiel-1.2/build/CMakeFiles/CMakeOutput.log" nor "/home/boris/Downloads/open_spiel-1.2/build/CMakeFiles/CMakeError.log" exist.
I have tried this on two different devices and neither of them worked.