OpenBW / openbw

OpenBW - free and open-source Best Wargame
159 stars 25 forks source link

Linker error with GCC 7.2.0 #3

Closed malcolmsharpe closed 6 years ago

malcolmsharpe commented 6 years ago

Following the build instructions in OpenBW/bwapi, it builds fine for me with GCC 6.x, but with GCC 7.2.0 I receive the following linker error. (Seen on two different OS, so I think it's really the compiler difference that matters.)

MacOS:

Linking CXX shared library ../../lib/libBWAPILIB.dylib
Undefined symbols for architecture x86_64:
  "std::allocator<BWAPI::UnitType>::allocator()", referenced from:
      __static_initialization_and_destruction_0(int, int) [clone .constprop.153] in UpgradeType.cpp.o
ld: symbol(s) not found for architecture x86_64

Linux:

[ 61%] Linking CXX executable ../../bin/BWAPILauncher
../../lib/libBWAPILIB.so: undefined reference to `std::allocator<BWAPI::UnitType>::allocator()'
collect2: error: ld returned 1 exit status

Alternatively to fixing this error, it would be fine to mention in the README what is the recommended compiler.

(Great project by the way! I'm new to it so I'm reporting some minor issues that I encountered while getting things set up.)

m1ndgames commented 6 years ago

Hi, i have the same issue with gcc 7.2.0:

[100%] Linking CXX executable ../../bin/BWAPILauncher
../../lib/libBWAPILIB.so: undefined reference to `std::allocator<BWAPI::UnitType>::allocator()'
collect2: error: ld returned 1 exit status
make[2]: *** [bwapi/BWAPILauncher/CMakeFiles/BWAPILauncher.dir/build.make:100: bin/BWAPILauncher] Error 1
make[1]: *** [CMakeFiles/Makefile2:448: bwapi/BWAPILauncher/CMakeFiles/BWAPILauncher.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
[florian@hacktop build]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release --enable-default-pie --enable-default-ssp
Thread model: posix
gcc version 7.2.0 (GCC)
tscmoo commented 6 years ago

If anyone knows what the issue is here, I'd appreciate it. I haven't had time to look into it. Some kind of linking issue I suppose?

BryanSWeber commented 6 years ago

Mild follow-up. I have tried downgrading gcc and g++ to 6.0. I followed: https://askubuntu.com/questions/724872/downgrade-gcc-from-5-2-1-to-4-9-ubuntu-15-10

The problem still persisted, this was the output, but it clearly thinks it is using g++/gcc v 6

[ 61%] Linking CXX executable ../../bin/BWAPILauncher
../../lib/libBWAPILIB.so: undefined reference to `std::allocator<BWAPI::UnitType>::allocator()'
collect2: error: ld returned 1 exit status
bwapi/BWAPILauncher/CMakeFiles/BWAPILauncher.dir/build.make:99: recipe for target 'bin/BWAPILauncher' failed
make[2]: *** [bin/BWAPILauncher] Error 1
CMakeFiles/Makefile2:447: recipe for target 'bwapi/BWAPILauncher/CMakeFiles/BWAPILauncher.dir/all' failed
make[1]: *** [bwapi/BWAPILauncher/CMakeFiles/BWAPILauncher.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
sc@sc-VirtualBox:~/bwapi/build$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 6.4.0-8ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.4.0 20171010 (Ubuntu 6.4.0-8ubuntu1) 
sc@sc-VirtualBox:~/bwapi/build$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 6.4.0-8ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.4.0 20171010 (Ubuntu 6.4.0-8ubuntu1) 
tscmoo commented 6 years ago

Fixed in https://github.com/OpenBW/bwapi/commit/035d4b0f034af696c6c6e97da3b980e025a92f3c