wiki:CompileWithVisualC
close Warning: Error with navigation contributor "AccountModule"

Version 20 (modified by chris, 3 years ago) (diff)

Update to Visual Studio 2012

Compiling Box Backup with Microsoft Visual C++

You will need quite a bit of software to make this work, but all of it is available for free on the Internet.

Microsoft Visual C++ 2012 Express Edition

Microsoft's Visual Studio is a commercial software development environment (IDE, compiler and tools) for Microsoft Windows. The Express Edition is available as a free download. Microsoft requires that you register it (free) within 30 days to get a license key.

Subversion

To get the source code for Box Backup out of an online version control repository, you will need a Subversion client for Windows with a command-line svn binary, such as SlikSVN.

Perl

Download and install ActivePerl for Windows. You might have to re-login to your system (or reboot your machine) after Windows Installer completes configuring the package, in order for Visual C++ and Command Prompt to recognize new and modified environment variables.

7-Zip

We recommend that you download and install the 7-zip archiver to extract compressed source code files.

Base Directory

Choose a directory where you will unpack and compile OpenSSL, Zlib, PCRE and Box Backup. We will call it a base directory, or <box-base> in code samples. An example might be:

C:\Users\Chris\BoxBackup

Make sure you know the full path to this directory. Enrique Perez-Terron reports that the OpenSSL make install step fails if the path contains spaces anywhere in the name, so please choose a path without spaces!

OpenSSL

You will need to compile OpenSSL using Visual C++.

  • Download the latest OpenSSL source code, e.g. openssl-1.0.2d.tar.gz
  • Right-click on the downloaded file and choose 7-Zip > Open archive
  • Inside the archive you will find a file called openssl-1.0.2d.tar, double-click on this to open it
  • Inside this archive you will find a folder called openssl-1.0.2d
  • Click on that folder and then click on the Extract button
  • Extract it to the base directory
  • Open a Visual Studio Command Prompt
  • Run the following commands:
    cd <base-dir>\openssl-1.0.0d
    perl Configure VC-WIN32 no-asm --prefix=<base-directory>\openssl
    ms\do_ms
    nmake -f ms\ntdll.mak
    nmake -f ms\ntdll.mak install
    

Zlib

You will need to download the latest Zlib compiled DLL from the Zlib website. Extract it into <box-base>\zlib. You don't need to compile anything.

PCRE

PCRE (Perl Compatible Regular Expressions) is a regular expression support package that is needed for Box Backup file exclusion and inclusion directives. Since it only supports autotools out of the box, we will follow the user-contributed CMake build process to compile it with Visual Studio instead:

  • Download the CMake latest stable release, binary distribution, Windows (Win32 Installer).
  • Install it, and during installation, select the option to Add CMake to the system PATH for all users.
  • Close any open command prompts (because they will not see the addition of CMake to the PATH).
  • Download the latest PCRE release (in ZIP format) from the official website
  • Right-click on the downloaded file and choose Extract all...
  • Extract to the base directory. Open that directory and rename pcre-<version> to just pcre.
  • Run CMake (cmake-gui) from the Start Menu.
  • For the source code directory, browse to <<base-directory>>/pcre.
  • For the binaries directory, browse to the same directory, click Make new folder and rename it to build, creating this folder inside the pcre directory.
  • Click on the Configure button, choose a compiler (probably Visual Studio 11 2012)
  • You should see CMake detecting compiler features, and eventually it should output the line Configuring done and display a list of options in red.
  • Do not change any options, click the Generate button to build the makefile. It should output the line Generating done.
  • Close the CMake GUI and open the PCRE.sln (Visual Studio Solution) file from the PCRE/build directory in Visual Studio.
  • Right-click on the pcre project (right-hand side of the Visual Studio window) and click Build.
  • Check that the Build output line shows 0 failed, and at least one succeeded or up-to-date.

Download Box Backup

To get the source code out of Subversion, open a command prompt, go to the base directory, and type:

svn co http://www.boxbackup.org/svn/box/trunk/ boxbackup

This should create a directory called boxbackup inside the base directory.

Inventory Check

Your complete <box-base> should now contain the following subdirectories:

  • boxbackup
  • openssl
  • pcre
  • zlib

Compile Box Backup

Open Visual C++. Choose "File/Open/Project?", navigate to the base directory, then to boxbackup\infrastructure\msvc\2012, and open the boxbackup.sln solution file in that directory.

Press F7 to compile Box Backup. If the compilation is successful, boxbackup\Debug\bbackupd.exe will be created.

Debugging

The executables in the boxbackup\Debug directory depend on DLLs which are not in your PATH. The easiest way to run the application under the debugger is to copy these DLLs into the Debug directory:

cd <base directory>\boxbackup
copy ..\openssl\libeay32.dll Debug
copy ..\openssl\ssleay32.dll Debug
copy ..\zlib\zlib1.dll Debug

Installation

Create the destination directory, C:\Program Files\Box Backup\bbackupd.

Write a configuration file, keys and certificate on a Unix machine, and copy them into the Box Backup directory, together with the following files from the base directory:

  • boxbackup\Release\bbackupd.exe
  • boxbackup\Release\bbackupquery.exe
  • boxbackup\Release\bbackupctl.exe
  • openssl\bin\libeay32.dll
  • openssl\bin\ssleay32.dll
  • zlib\zlib1.dll

Ensure that the user running Box Backup can read from the Box Backup directory, and write to the bbackupd directory inside it.

Run Box Backup by double-clicking on it, and check that it connects to the server. If the window opens and closes immediately, it's probably due to a problem with the configuration file - check the Windows Event Viewer for details.

See also the service installation and upgrade instructions on the CompilationOnWindows page.