Compile(make) error

Hi, i get error on my Mac OSX 10.6.7 when i try compile it.
./configure is ok

[soudruh@MacBookPro][11:28:37][~/heroes/trunk]
$./configure 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of g++... gcc3
checking build system type... x86_64-apple-darwin10.7.0
checking host system type... x86_64-apple-darwin10.7.0
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld
checking if the linker (/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm
checking the name lister (/usr/bin/nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 196608
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld option to reload object files... -r
checking for objdump... no
checking how to recognize dependent libraries... pass_all
checking for ar... ar
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm output from gcc object... ok
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking dependency style of g++... (cached) gcc3
checking how to run the C++ preprocessor... g++ -E
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fno-common -DPIC
checking if gcc PIC flag -fno-common -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin10.7.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking for ld used by g++... /usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld
checking if the linker (/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld) is GNU ld... no
checking whether the g++ linker (/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fno-common -DPIC
checking if g++ PIC flag -fno-common -DPIC works... yes
checking if g++ static flag -static works... no
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin10.7.0 dyld
checking how to hardcode library paths into programs... immediate
checking for C++ compiler vendor... gnu
checking for boostlib >= 1.36... yes
checking whether the Boost::System library is available... yes
checking for exit in -lboost_system-mt... yes
checking whether the Boost::Filesystem library is available... yes
checking for exit in -lboost_filesystem-mt... yes
checking whether the Boost::Thread library is available... yes
checking for exit in -lboost_thread-mt... yes
checking whether the Boost::IOStreams library is available... yes
checking for exit in -lboost_iostreams-mt... yes
checking whether the Boost::Program_Options library is available... yes
checking for exit in -lboost_program_options-mt... yes
checking for sdl-config... yes
checking SDL/SDL.h usability... yes
checking SDL/SDL.h presence... yes
checking for SDL/SDL.h... yes
checking SDL/SDL_mixer.h usability... yes
checking SDL/SDL_mixer.h presence... yes
checking for SDL/SDL_mixer.h... yes
checking SDL/SDL_image.h usability... yes
checking SDL/SDL_image.h presence... yes
checking for SDL/SDL_image.h... yes
checking SDL/SDL_ttf.h usability... yes
checking SDL/SDL_ttf.h presence... yes
checking for SDL/SDL_ttf.h... yes
checking for SDL_Init in -lSDL... yes
checking for main in -lSDL_mixer... yes
checking for IMG_Load in -lSDL_image... yes
checking for main in -lSDL_ttf... yes
checking for av_open_input_file in -lavformat... yes
checking for sws_getContext in -lswscale... yes
checking for avcodec_decode_video2 in -lavcodec... yes
checking for ANSI C header files... (cached) yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking boost/filesystem.hpp usability... yes
checking boost/filesystem.hpp presence... yes
checking for boost/filesystem.hpp... yes
checking boost/algorithm/string.hpp usability... yes
checking boost/algorithm/string.hpp presence... yes
checking for boost/algorithm/string.hpp... yes
checking boost/algorithm/string/replace.hpp usability... yes
checking boost/algorithm/string/replace.hpp presence... yes
checking for boost/algorithm/string/replace.hpp... yes
checking boost/filesystem/operations.hpp usability... yes
checking boost/filesystem/operations.hpp presence... yes
checking for boost/filesystem/operations.hpp... yes
checking boost/assign/std/vector.hpp usability... yes
checking boost/assign/std/vector.hpp presence... yes
checking for boost/assign/std/vector.hpp... yes
checking boost/algorithm/string/find.hpp usability... yes
checking boost/algorithm/string/find.hpp presence... yes
checking for boost/algorithm/string/find.hpp... yes
checking boost/function.hpp usability... yes
checking boost/function.hpp presence... yes
checking for boost/function.hpp... yes
checking boost/bind.hpp usability... yes
checking boost/bind.hpp presence... yes
checking for boost/bind.hpp... yes
checking for atexit... yes
checking for memset... yes
checking for pow... yes
checking for select... yes
checking for sqrt... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating lib/Makefile
config.status: creating client/Makefile
config.status: creating server/Makefile
config.status: creating AI/Makefile
config.status: creating AI/StupidAI/Makefile
config.status: creating AI/GeniusAI/Makefile
config.status: creating AI/EmptyAI/Makefile
config.status: executing depfiles commands
config.status: executing libtool commands

But when i do make i get error:

soudruh@MacBookPro][11:47:53][~/heroes/trunk]
$make
Making all in lib
  CXX    libvcmi_la-ERMInterpreter.lo
In file included from ERMInterpreter.cpp:2:
ERMInterpreter.h: In constructor ‘VERMInterpreter::VermTreeIterator::VermTreeIterator(VERMInterpreter::VOptionList&)’:
ERMInterpreter.h:488: warning: ‘VERMInterpreter::VermTreeIterator::basePos’ will be initialized after
ERMInterpreter.h:487: warning:   ‘VERMInterpreter::VermTreeIterator::Estate VERMInterpreter::VermTreeIterator::state’
ERMInterpreter.h:490: warning:   when initialized here
ERMInterpreter.h: In constructor ‘VERMInterpreter::VFunc::VFunc(const VERMInterpreter::VOptionList&)’:
ERMInterpreter.h:532: warning: ‘VERMInterpreter::VFunc::body’ will be initialized after
ERMInterpreter.h:530: warning:   ‘VERMInterpreter::VFunc::Eopt VERMInterpreter::VFunc::option’
ERMInterpreter.h:533: warning:   when initialized here
ERMInterpreter.cpp: In member function ‘VERMInterpreter::VOption VNodeEvaluator::operator()(const VERMInterpreter::VSymbol&) const’:
ERMInterpreter.cpp:2549: error: no match for call to ‘(VERMInterpreter::VFunc) (VERMInterpreter::VOptionList)’
ERMInterpreter.h:549: note: candidates are: VERMInterpreter::VOption VERMInterpreter::VFunc::operator()(VERMInterpreter::VermTreeIterator)
/opt/local/include/boost/system/error_code.hpp: At global scope:
/opt/local/include/boost/system/error_code.hpp:214: warning: ‘boost::system::posix_category’ defined but not used
/opt/local/include/boost/system/error_code.hpp:215: warning: ‘boost::system::errno_ecat’ defined but not used
/opt/local/include/boost/system/error_code.hpp:216: warning: ‘boost::system::native_ecat’ defined but not used
make[1]: *** [libvcmi_la-ERMInterpreter.lo] Error 1
make: *** [all-recursive] Error 1

Can anyone help mi with compiling source from svn branch on Mac?

This error was fixed in svn two days ago. Try updating your source code - currently everything works fine (revision 2183).

Hi, I am able to configure but get this error message when running make:

Making all in lib
make  all-am
  CXX    libvcmi_la-CLodHandler.lo
  CXX    libvcmi_la-map.lo
  CXXLD  libvcmi.la
Making all in client
make  all-am
  CXX    vcmiclient-CPreGame.o
  CXXLD  vcmiclient
Making all in server
make  all-am
  CXX    vcmiserver-CVCMIServer.o
  CXXLD  vcmiserver
ld: library not found for -lrt
collect2: ld returned 1 exit status
make[2]: *** [vcmiserver] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1

I particularly don’t get the ld: message. I assume I am missing a library, but it doesn’t tell me which. Is there a more verbose option? or something that i might need other than what is mentioned in README.linux?
also has anyone been successful in building for OS X?

thanks for your help

Check [forum.vcmi.eu/t/heroes-3-on-mac-os-x/421/1)

A warning and an error:

Also, in the same place, mergable should be spelled mergeable.

It is a bug, a temporary is passed as an output argument for a function. I’ll fix this soon.

EDIT: Fixed in r2586.

Since last Ivan’s commit (r2871) I cannot compile VCMI on my OpenSUSE:

VCAI.cpp: In member function 'bool VCAI::tryBuildStructure(const CGTownInstance*, int, unsigned int)':
VCAI.cpp:1270:33: error: 'class CTown' has no member named 'buildings'
VCAI.cpp:1285:31: error: 'class CTown' has no member named 'buildings'

“make clean” does not help. Including CTownHandler.h in VCAI.cpp produces even more bizarre and inexplicable errors. Any ideas?

“make clean” does not removes precompiled headers (.gch files). And it looks that AI/VCAI/StdInc.h includes most of library headers (bad idea I think - our lib headers change quite often).

Removing AI/VCAI/*.gch file should fix this.

I usually use CMake + Clang - works twice faster compared to autotools + gcc without bizarre bugs like this.

Bad idea when you work on lib part; good idea when you are working on the AI part only, as I did for quite a while. I however I don’t anymore, lib includes in PCH can go. :stuck_out_tongue: And they should if they cause trouble for make/gcc users.

I thought about PCH, but I assumed that make clean removes them. Strange behavior.

What should I do to switch to Clang? Does it produce reasonable debug info for gdb? Currently I’m trying to set up development environment on Linux to familiarize myself with it but it’s more time consuming than I thought. I assumed that make install does something different than placing symlinks in appropriate places and now I’m discovering what should go where – and apparently it changed since I last run VCMI under Linux, about a year ago.

Calling configure (or cmake) with environment variables CC=clang CXX=clang++ should suffice, at least it once did for me AFAIR. You’ll need a Clang 3.1 that was released in May (or svn build).
I believe it should work with GDB just like GCC.

PCH work somewhat weird: sometimes make will recompile them, sometimes it will not.
And I haven’t found any way to fix them except for removing. I left PCH because system headers are not likely to change.

VCMI needs latest clang (3.1) and at least boost 1.48 - higher version than gcc due to bug in boost.
Debug info with clang looks to be on the same level as gcc - I assume that it can be described as “reasonable”.

To use it with autotools rerun configure:
CC=clang CXX=clang++ /configure

With cmake:
CC=clang CXX=clang++ cmake -DCMAKE_BUILD_TYPE=Debug

It does actual installation - copies all binaries to install path.
All symlinks should be placed manually. Maybe I should add something like “make symlinks” to cmake? :slight_smile:
Symlinks that I have created for cmake:

.../bin/vcmiserver             -> .../build/server/vcmiserver
.../lib/vcmi/AI/libStupidAI.so -> .../build/AI/StupidAI/libStupidAI.so
.../lib/vcmi/AI/libVCAI.so     -> .../build/AI/VCAI/libVCAI.so
.../lib/vcmi/libvcmi.so        -> .../build/lib/libvcmi.so

Autotools uses a bit different directory structure - binaries are in hidden subdirectories. For example path to client will be
/client/.libs/vcmiclient