Halite icon indicating copy to clipboard operation
Halite copied to clipboard

How to compile Halite?

Open apexlee opened this issue 9 years ago • 6 comments

There are no instructions on how to compile and no where to contact author to find this out.

Anybody managed to do this and have some tips?

apexlee avatar Aug 10 '15 17:08 apexlee

Sad, but I failed to do anything in VS2015 as main developer commented.

maxdeepfield avatar Aug 20 '15 08:08 maxdeepfield

Hi, I'm not ignoring this issue, I'm just very busy these days. I have switched over to Visual Studio 2015 Community myself. The last release archive won't build with it, but the the code here on GitHub does from revision 69118b49aa6fb0457c8c7a6310f4d78e791c6077 onwards.

Eoinocal avatar Aug 23 '15 14:08 Eoinocal

Here's some quick notes on how I got it to build and launch with the current version (though it launches invisible). The quick list of dependencies is:

  • MFC classes in Visual Studio
  • Boost
  • libtorrent
  • OpenSSL
  • ActivePerl added to your system/user PATH environment variable. May require reboot.

Make sure you've installed Visual Studio with the MFC package. If not, launch the installer again and modify your installation. Download boost prebuilt binaries from http://www.boost.org/users/download/ While that's downloading, make a "lib" directory in the root of the repository. inside it clone libtorrent from git://github.com/arvidn/libtorrent.git and checkout tag libtorrent-1_0_6 (or newer if available). Go to http://sourceforge.net/projects/wtl/ and download Windows Template Library. On the C drive create the following path C:\Craftwork\Cpp\Dependencies. Inside it, create the folders include and libs-windows-x64 (I wouldn't even bother with x86 any more). I think the last thing you'll need is OpenSSL. Clone it from git://github.com/openssl/openssl.git and check-out the latest stable version. To build OpenSSL open a VS2015 x64 Native Tools Command Prompt (a step they neglect, because they're linux-people) and go to the directory where you cloned it. From then on their instructions worked directly without need to modify (at least for me).

perl Configure VC-WIN64A
ms\do_win64a
nmake -f ms\ntdll.mak

If the second one tells you it's not found, try adding .bat at the end. Also you may be running it in cygwin, which is a horrible idea. All the output files are in out32dll. Never mind that it doesn't say 64. You need to copy ssleay32.lib and libeay32.lib to C:\Craftwork\Cpp\Dependencies\libs-windows-x64 and rename them respectively libssleay32-vc140-mt-sgd.lib and libeay32-vc140-mt-sgd.lib. You will also need to copy libeay32.dll and ssleay32.dll to your executable folder once the project is built, so you might want to put them somewhere convenient. In the OpenSSL folder there is now an inc32 folder containing an openssl folder. Copy the openssl one (not just it's contents) to C:\Craftwork\Cpp\Dependencies\include

Extract the WTL files directly in C:\Craftwork\Cpp\Dependencies\include.

Assuming Boost has been downloaded, extract it anywhere and inside it there is a boost directory which you also need to copy to C:\Craftwork\Cpp\Dependencies\include. There is also a lib64-msvc-14.0 directory. Copy everything from it to C:\Craftwork\Cpp\Dependencies\libs-windows-x64. I don't really know if any of those boost libraries are required for the linkage, but the includes are definitely required.

Now back to the project, open lib/libtorrent/src/http_connection.cpp. Near line 158, You will find three snprintf calls, that will fail to compile. change them to this:

#define APPEND_FMT(fmt) ptr += snprintf(ptr, int(end - ptr), fmt)
#define APPEND_FMT1(fmt, arg) ptr += snprintf(ptr, int(end - ptr), fmt, arg)
#define APPEND_FMT2(fmt, arg1, arg2) ptr += snprintf(ptr, int(end - ptr), fmt, arg1, arg2)

The typecast gets you past the ambiguous call error. Do the same in lib/libtorrent/src/kademlia/item.cpp at line 72. Finally you need to edit lib/libtorrent/src/utf8.cpp and add the following directive somewhere near the others.

#include <iterator>

I'm guessing in previous versions of Visual Studio that one was included by one of the other dependencies.

This is what got me past building. Once I built it, I had to copy those two DLL files I mentioned earlier to where the EXE is.

Edit: they turned out not-so-quick.

coladict avatar Sep 15 '15 18:09 coladict

Hi coladict, thanks for writing those up, you got everything pretty much bang on. Two additions:

First. The folder C:\Craftwork\Cpp\Dependencies\* is my own personal set-up but I imagine different people have their own set-ups they would like to stick with. The path is set in the Halite Dependencies Property Page. The attached image shows where to find that setting and how to change it if anyone wants. You only need to make the change once and it will be applied for all other projects and build variants.

halite props

Second. If you'd prefer not have to copy around the extra OpenSSL related DLLs, you can instead use the ms\nt.mak make file to build static libraries.

Eoinocal avatar Sep 15 '15 19:09 Eoinocal

Tried the ms\nt.mak thing. Good plan, didn't work. The scripts for making it are far form x64-ready. I might have time to work on that after next week, but OpenSSL is another project altogether.

coladict avatar Sep 16 '15 08:09 coladict

I've managed to build x64/Release Halite on AppVeyor and if CI is needed I can submit a PR.

l2dy avatar Jan 20 '17 13:01 l2dy