fph / bastet

Evil falling block game. http://fph.altervista.org/prog/bastet.html
GNU General Public License v3.0
272 stars 35 forks source link

Build fails with libc++ #1

Closed ryandesign closed 9 years ago

ryandesign commented 10 years ago

Building bastet 0.43 fails on OS X 10.9 Mavericks. With this version of OS X, Apple has switched the default C++ library from libstdc++ to libc++, which does not include experimental pre-standardization C++11 features such as the ones you're using in your code; it only supports the final C++11 standard.

--->  Building bastet
DEBUG: Executing org.macports.build (bastet)
DEBUG: Environment: 
CC_PRINT_OPTIONS='YES'
CC_PRINT_OPTIONS_FILE='/opt/local/var/macports/build/_Users_rschmidt_macports_dports_games_bastet/bastet/work/.CC_PRINT_OPTIONS'
CPATH='/opt/local/include'
LIBRARY_PATH='/opt/local/lib'
MACOSX_DEPLOYMENT_TARGET='10.9'
DEBUG: Assembled command: 'cd "/opt/local/var/macports/build/_Users_rschmidt_macports_dports_games_bastet/bastet/work/bastet-0.43" && /usr/bin/make -w all CXX=/usr/bin/clang++ CXXFLAGS="-Os -arch x86_64" LDFLAGS="-L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64" PREFIX=/opt/local'
DEBUG: Executing command line:  cd "/opt/local/var/macports/build/_Users_rschmidt_macports_dports_games_bastet/bastet/work/bastet-0.43" && /usr/bin/make -w all CXX=/usr/bin/clang++ CXXFLAGS="-Os -arch x86_64" LDFLAGS="-L/opt/local/lib -Wl,-headerpad_max_install_names -arch x86_64" PREFIX=/opt/local 
make: Entering directory `/opt/local/var/macports/build/_Users_rschmidt_macports_dports_games_bastet/bastet/work/bastet-0.43'
Makefile:14: depend: No such file or directory
/usr/bin/clang++ -MM Ui.cpp main.cpp Block.cpp Well.cpp BlockPosition.cpp Config.cpp BlockChooser.cpp BastetBlockChooser.cpp > depend
In file included from Ui.cpp:22:
./BastetBlockChooser.hpp:26:10: fatal error: 'tr1/unordered_set' file not found
#include <tr1/unordered_set>
         ^
1 error generated.
In file included from main.cpp:21:
./BastetBlockChooser.hpp:26:10: fatal error: 'tr1/unordered_set' file not found
#include <tr1/unordered_set>
         ^
1 error generated.
In file included from BastetBlockChooser.cpp:19:
./BastetBlockChooser.hpp:26:10: fatal error: 'tr1/unordered_set' file not found
#include <tr1/unordered_set>
         ^
1 error generated.
make: *** [depend] Error 1
make: Leaving directory `/opt/local/var/macports/build/_Users_rschmidt_macports_dports_games_bastet/bastet/work/bastet-0.43'

If you do not have access to a Mac, you should be able to reproduce this on any other system that has libc++ available.

fph commented 10 years ago

I've switched to using std::unordered_set rather than std::tr1::unordered_set; this should hopefully fix the issue. On my machine I can compile, but not link because my version of libboost-dev is compiled with libstdc++ (and it's not binary compatible with libc++). I'd be happy if you could test the latest version in the trunk and tell me if it works on a Mac (see also #2 for how to link against libboost-mt). Thanks for the reports.

ryandesign commented 10 years ago

Thanks. This does work on OS X 10.9 now, but would fail on any earlier version, at least using any of the compilers that come with the Apple development environment Xcode, because they all use the system's C++ library, which on OS X 10.8 and earlier is based on libstdc++ from GCC around version 4.2.1 and therefore don't understand C++11. For example on Mac OS X 10.5 using its default compiler—the Apple-modified version of GCC 4.0.1 that comes with the appropriate version of Xcode—I get:

cc1plus: error: unrecognized command line option "-std=c++11"

Using a newer GCC compiler (4.8.2) installed by MacPorts does work for me on 10.5 (because GCC compilers come bundled with a newer version of libstdc++) but I hate using up the user's time, bandwidth and disk space to install a whole new compiler. And there can sometimes be compatibility problems when mixing a newer GCC's libstdc++ with Apple's older libstdc++ in the same process (which is what happens here, since you're using boost which was compiled with the system's libstdc++), although in this case bastet seems to run ok.

fph commented 10 years ago

I see -- so on OS X 10.8 there is neither c++11 support, nor preliminary tr1 features? This could be a problem, as I am using a tr1 container for better performance (unordered_set). I can switch to the tr1 implementation contained in Boost; I guess that one should work.

fph commented 10 years ago

Let's keep this open until @ryandesign confirms it works on older Macs as well.

ryandesign commented 10 years ago

On OS X 10.8 and earlier, there is preliminary tr1 support. Thus bastet 0.43, without changes, compiles fine on OS X 10.8 and earlier.

I'll test your new changes soon.

ryandesign commented 9 years ago

Sorry for the delay. The latest commit, 2c9d978e22ea78f47e3c522ac7c11d2223a1b8b4, builds and runs fine both on OS X 10.10 (with libc++) and 10.6 (with libstdc++).