TorchCraft / TorchCraftAI

A platform that lets you build agents to learn to play StarCraft: Brood War.
https://torchcraft.github.io/TorchCraftAI
MIT License
650 stars 123 forks source link

[Linux]Cherrypi build error on bwapilib #18

Closed ianchen28 closed 5 years ago

ianchen28 commented 5 years ago

got the error when running 'make' in the following:

mkdir -p build cd build cmake .. -DCMAKE_BUILD_TYPE=relwithdebinfo -DWITH_CPIDLIB=OFF make -j$(nproc)

whole log as follows:

[ 26%] Building CXX object 3rdparty/torchcraft/BWEnv/CMakeFiles/BWEnvClient.dir/src/main.cc.o [ 26%] Building CXX object 3rdparty/torchcraft/BWEnv/CMakeFiles/BWEnv.dir/src/dll.cc.o [ 26%] Building CXX object 3rdparty/torchcraft/BWEnv/CMakeFiles/BWEnv.dir/src/module.cc.o [ 26%] Linking CXX executable BWEnvClient [ 26%] Linking CXX shared library libbwapilib.so [ 26%] Built target bwapilib Scanning dependencies of target bwem /usr/include/c++/7/bits/basic_string.h:133: error: undefined reference to 'BWAPI::Type<BWAPI::Error, 27>::typeNames[abi:cxx11]' /home/chenyuyang01/git/TorchCraftAI/3rdparty/torchcraft/BWEnv/src/controller.cc:195: error: undefined reference to 'BWAPI::Type<BWAPI::Race, 8>::typeNames[abi:cxx11]' /home/chenyuyang01/git/TorchCraftAI/3rdparty/torchcraft/BWEnv/src/controller.cc:205: error: undefined reference to 'BWAPI::Type<BWAPI::Race, 8>::typeNames[abi:cxx11]' /home/chenyuyang01/git/TorchCraftAI/3rdparty/torchcraft/BWEnv/src/controller.cc:422: error: undefined reference to 'BWAPI::Type<BWAPI::Error, 27>::typeNames[abi:cxx11]' /home/chenyuyang01/local/usr/local/include/BWAPI/Type.h:97: error: undefined reference to 'BWAPI::Type<BWAPI::Error, 27>::typeNames[abi:cxx11]' collect2: error: ld returned 1 exit status 3rdparty/torchcraft/BWEnv/CMakeFiles/BWEnvClient.dir/build.make:104: recipe for target '3rdparty/torchcraft/BWEnv/BWEnvClient' failed make[2]: [3rdparty/torchcraft/BWEnv/BWEnvClient] Error 1 CMakeFiles/Makefile2:694: recipe for target '3rdparty/torchcraft/BWEnv/CMakeFiles/BWEnvClient.dir/all' failed make[1]: [3rdparty/torchcraft/BWEnv/CMakeFiles/BWEnvClient.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... [ 26%] Building CXX object 3rdparty/bwem/CMakeFiles/bwem.dir/area.cpp.o [ 26%] Building CXX object 3rdparty/bwem/CMakeFiles/bwem.dir/cp.cpp.o [ 26%] Building CXX object 3rdparty/bwem/CMakeFiles/bwem.dir/base.cpp.o [ 26%] Building CXX object 3rdparty/bwem/CMakeFiles/bwem.dir/map.cpp.o [ 28%] Building CXX object 3rdparty/bwem/CMakeFiles/bwem.dir/gridMap.cpp.o

danthe3rd commented 5 years ago

I'm sorry you're having errors again :/ If I recall correctly, there was a change in GCC ABI at version 6. In short, code compiled with version 6+ doesn't link with code compiled with version <= 5. And from the log, it looks like you have installed system wide BWAPI?

Can you provide:

  1. The version of gcc or clang that you use
  2. The content of the file build/CMakeCache.txt

Thank you

ianchen28 commented 5 years ago

I'm sorry you're having errors again :/ If I recall correctly, there was a change in GCC ABI at version 6. In short, code compiled with version 6+ doesn't link with code compiled with version <= 5. And from the log, it looks like you have installed system wide BWAPI?

Can you provide:

  1. The version of gcc or clang that you use
  2. The content of the file build/CMakeCache.txt

Thank you

The reason turned out to be the BWAPI I compiled previously with GCC 4.x, while cherrypi with GCC 7.1 : P A little complex but finally fixed by re-compile all the dependancies with GCC 7.1, according to your instruction. And currently everything run correctly, Thank you~

One more thing, I encountered another error as https://github.com/OpenBW/openbw/issues/3#issue-267579749 and fixed by applying the same fix https://github.com/OpenBW/bwapi/commit/035d4b0f034af696c6c6e97da3b980e025a92f3c also to the file https://github.com/TorchCraft/TorchCraftAI/blob/afce4b6004712e2c32ab825ad705608f8c042fc8/3rdparty/bwapilib/UnitType.cpp#L11-L13 Maybe you can have a look if you should also apply the fix in your code?

Thank you again for your time : )

danthe3rd commented 5 years ago

I'm glad that you got it working! Let us know if you have any further issue using the codebase

Also thank you for pointing out this gcc 7.1 bug, I'll make sure to include the fix on the next code push :)