Compiling VCMI

Hi guys, I’m very glad to become one member of VCMI. I registered just now. I have been a big fan of heros 3 since I was a kid. :slight_smile:

I’m now reading the code, build it and try to do some improvement if possible. I tried to build the source on both Ubuntu 12.04 and Maverick(OSx 10.9). I’ve already solved a lot of problems I encountered, but still failed to deal with some difficulties. I did a lot of research on Google, but without luck, still can’t solve it. Could you guys help me out? I would really appreciate it.

Here are the problems:

Source version: vcmi-0.95 (release)

1.Building on Maverick(OSx 10.9):

I followed exactly as what the wiki says to build on Mac OS. I installed the boost and sdl2 library through Homebrew. Then after I ran cmake, it also complains about the SDL2 related error. So I searched online, and got the SDL2_image, SDL2_mixer and SDL2_ttf framework, then put them into the /Library/Framworks directory (as the official website says). And after I ran cmake, it shows me the following message:

-- Boost version: 1.51.0
-- Found the following Boost libraries:
--   program_options
--   filesystem
--   system
--   thread
--   locale
-- checking for module 'SDL2_image'
--   package 'SDL2_image' not found
-- checking for module 'SDL2_mixer'
--   package 'SDL2_mixer' not found
-- checking for module 'SDL2_ttf'
--   package 'SDL2_ttf' not found
-- cotire 1.5.2 loaded.
-- Configuring done
CMake Warning (dev):
  Policy CMP0042 is not set: MACOSX_RPATH is enabled by default.  Run "cmake
  --help-policy CMP0042" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  MACOSX_RPATH is not specified for the following targets:


This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /Users/dreamer/workspace/vcmi/build

I’m not sure why it still complains that it can’t find the SDL2 related package. Since no error generated, I assumed it’s good to build the code with XCode and moved on to the next step. I started XCode, click ‘Build’. The compilation is pretty good, but when linking to library, error occurred:

Ld bin/Debug/libvcmi.dylib normal x86_64
    cd /Users/dreamer/workspace/vcmi
    /Applications/ -arch x86_64 -dynamiclib -isysroot /Applications/ -L/Users/dreamer/workspace/vcmi/bin/Debug -F/Users/dreamer/workspace/vcmi/bin/Debug -filelist /Users/dreamer/workspace/vcmi/build/lib/ -install_name @rpath/libvcmi.dylib -Xlinker -rpath -Xlinker @executable_path/../Frameworks -Xlinker -rpath -Xlinker @executable_path/ -mmacosx-version-min=10.9 -dynamiclib -Wl,-headerpad_max_install_names /Users/dreamer/workspace/vcmi/bin/Debug/libminizip.dylib /Users/dreamer/workspace/lib/libboost_program_options.a /Users/dreamer/workspace/lib/libboost_filesystem.a /Users/dreamer/workspace/lib/libboost_system.a /Users/dreamer/workspace/lib/libboost_thread.a /Users/dreamer/workspace/lib/libboost_locale.a /usr/local/lib/libSDL2.dylib -framework Cocoa /usr/lib/libz.dylib -liconv -ldl -stdlib=libc++ -single_module -Xlinker -dependency_info -Xlinker /Users/dreamer/workspace/vcmi/build/lib/ -o /Users/dreamer/workspace/vcmi/bin/Debug/libvcmi.dylib

Undefined symbols for architecture x86_64:
  "VCMIDirsOSX::libraryName(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) const", referenced from:
      vtable for VCMIDirsOSX in VCMIDirs.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I tried very hard, but really can’t solve this problem. :’(

2.Building on Ubuntu 12.04:

This Ubuntu is installed on my Parallel 9 on my Maverick. I updated gcc and g++ from 4.6 to 4.7 to support the C++11.

After solving all the dependency issues, I typed “make” to build the whoe project. If I just type make to build, then the compilation stucks when it’s trying link(compile?) the “GameState.cpp.o” (I don’t quite remember the exact name). If I type “make -j2”, it also stuck at this step. I mean the terminal just hangs there(like busy waiting).

I’m not sure if this is caused by the dependencies of multiple threading when run ubuntu on VM. I’ve already ordered a 256G SSD for my old laptop, and plan to install a real ubuntu on that machine. I’ll try compile the project again on that machine tomorrow when it’s delivered.

I really want to delve into this project and really appreciate your help. Thank you! :slight_smile:

Looks like bug in VCMI. Can you check file lib/VCMI_Dirs.cpp and implement that method for Mac OS? IIRC it should generate full filename of libraries on your system, e.g. VCAI should result in VCAI.dll on Win or on Linux.

Known bug, kind of. Compilation may require up to ~2 Gb per process. Caused by overusing templates in some places, not sure what we can do here.

Hi Ivan, thank you for your replay.

I’m now travelling for some meeting. When having time, I’ll have a look at them.

For the Linux build, I installed a Ubuntu 14.04 on my new SSD drive, and build it on this system. Although it takes a while, it’s built successfully now. Then I linked the binary as described in the instructions. But still got errors like: “Heroes III data is not found”. It seems CConsoleHandler can’t find the HELP.txt file and I realized that the Hero III data and vcmi data need to be installed. The next step for me is to download and install these data files. If got any problems, I would update my installation status accordingly. :->

Yeah. VCMI needs H3 data to function.

You need to provide it in one of locations vcmi checks for (normally - /usr/local/share/vcmi or ~/.local/share/vcmi). You can either install it manually or check vcmibuilder script.

As for “vcmi data” - in current trunk this data is already here. All you need to do is to link/copy Mods directory from git.