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 if boost is only installed multi-threaded #2

Closed ryandesign closed 6 years ago

ryandesign commented 10 years ago

bastet 0.43 assumes the single-threaded library boost_program_options is available, but it is possible to compile boost with only multi-threaded support, in which case only the library boost_program_options-mt will be available; this is the case in MacPorts for example, resulting in e.g. this build failure on Mac OS X 10.5:

--->  Building bastet
DEBUG: Executing org.macports.build (bastet)
DEBUG: Environment: CPATH='/opt/local/include' CC_PRINT_OPTIONS_FILE='/opt/local/var/macports/build/_Users_rschmidt_macports_dports_games_bastet/bastet/work/.CC_PRINT_OPTIONS' LIBRARY_PATH='/opt/local/lib' CC_PRINT_OPTIONS='YES' MACOSX_DEPLOYMENT_TARGET='10.5'
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/g++-4.2 CXXFLAGS="-Os -arch i386" LDFLAGS="-L/opt/local/lib -Wl,-headerpad_max_install_names -arch i386" 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/g++-4.2 CXXFLAGS="-Os -arch i386" LDFLAGS="-L/opt/local/lib -Wl,-headerpad_max_install_names -arch i386" 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/g++-4.2 -MM Ui.cpp main.cpp Block.cpp Well.cpp BlockPosition.cpp Config.cpp BlockChooser.cpp BastetBlockChooser.cpp > depend
make: Leaving directory `/opt/local/var/macports/build/_Users_rschmidt_macports_dports_games_bastet/bastet/work/bastet-0.43'
make: Entering directory `/opt/local/var/macports/build/_Users_rschmidt_macports_dports_games_bastet/bastet/work/bastet-0.43'
/usr/bin/g++-4.2 -Os -arch i386   -c -o Ui.o Ui.cpp
/usr/bin/g++-4.2 -Os -arch i386   -c -o main.o main.cpp
/usr/bin/g++-4.2 -Os -arch i386   -c -o Block.o Block.cpp
/usr/bin/g++-4.2 -Os -arch i386   -c -o Well.o Well.cpp
/usr/bin/g++-4.2 -Os -arch i386   -c -o BlockPosition.o BlockPosition.cpp
/usr/bin/g++-4.2 -Os -arch i386   -c -o Config.o Config.cpp
/usr/bin/g++-4.2 -Os -arch i386   -c -o BlockChooser.o BlockChooser.cpp
/usr/bin/g++-4.2 -Os -arch i386   -c -o BastetBlockChooser.o BastetBlockChooser.cpp
/usr/bin/g++-4.2 -ggdb -o bastet Ui.o main.o Block.o Well.o BlockPosition.o Config.o BlockChooser.o BastetBlockChooser.o -L/opt/local/lib -Wl,-headerpad_max_install_names -arch i386 -lboost_program_options
ld: library not found for -lboost_program_options
collect2: ld returned 1 exit status
make: *** [bastet] Error 1
make: Leaving directory `/opt/local/var/macports/build/_Users_rschmidt_macports_dports_games_bastet/bastet/work/bastet-0.43'

Usually detecting whether to use the single-threaded or multi-threaded boost libraries is something you would do in your configure script; since bastet does not have a configure script, I'm not sure what you should do. I suppose you could at least offer a Makefile variable for controlling the boost library suffix, but ideally you would detect it automatically and use the best-available library.

fph commented 10 years ago

Committed a quick fix (added a Makefile variable, as you suggest). Please test with BOOST_PO=-lboost_program_options-mt make; works on my machine. But I agree with you that the way to go for better compatibility is migrate to autotools; this will be my next goal for closing this issue.

ryandesign commented 10 years ago

Thanks.

BOOST_PO=-lboost_program_options-mt CPPFLAGS=-isystem/opt/local/include LDFLAGS=-L/opt/local/lib make

does not work because the line you added

BOOST_PO+=-lboost_program_options

appends -lboost_program_options to BOOST_PO when what you probably want is to just set it if it's not set, which you could do with:

BOOST_PO?=-lboost_program_options

Alternately, the following works with your current code:

CPPFLAGS=-isystem/opt/local/include LDFLAGS=-L/opt/local/lib make BOOST_PO=-lboost_program_options-mt

However it's confusing when some options must be given as environment variables and other options must be given as arguments.

fph commented 10 years ago

My bad - I mixed up ?= and +=. I'm fixing that immediately.

ryandesign commented 9 years ago

Sorry for the delay. I'm satisfied with this solution for now. If you want to switch to autotools later, that could be a separate ticket.