This site is deprecated. The new site can be found here: http://nsclient.org.
For specific sections: issues (existing issues will be handled here), forums, news, documentation.

Version 34 (modified by mickem, 2 years ago) (diff)

--

Building the 0.4.x branch

Since I just got a new machine I figured I'd write this quick summary if anyone else is interested in setting this up.

Required Tooling:

  • CMake 2.6
  • Python 2.7
  • nmake

Optional Tooling:

  • Nasm 2.10
  • Perl 5.12 (for openssl)

Before you begin:

  • Make sure all paths are ok.
    cmake --version
    python -V
    perl -v
    nasm -v
    nmake /help
    

Required Libraries:

  • boost 1.49.0 (no later versions currently, see note below)
  • Google Protocol Buffers 2.4.1

Optional Libraries:

  • crypto++ 5.6.1
  • lua 5.2.1
  • openssl 1.0.1c
  • Google Break Pad (svn)
  • tinyxml2
  • zeromq-2.2.0

Building all dependencies

I think the simplest way to manage dependencies (since most tools does not cater well for multi architecture builds) is to have separate folders for W32 and x64. Hence I create a root folder for each architecture. If you are only interested in a single architecture you can thus ignore the other one and make your life simpler. In general most "tinkering" is required for x64 builds so if you want an easy out go for w32.

Automatic!

There is a script in progress which is designed to help download and build all dependencies on a visual studio 2005 machine (it could with little or no change be adapted to other versions of visual studio as well). The script is a python script which should be run with all your environment variables setup correctly so be sure to read-on the other sections to make sure everything is in order. NOTICE This is highly experimental and requires "you" to read and understand what goes on so don't expect too much but feel free to help make improvements if you run into any snags :)

To expand a bit on all your environment variables. This is very important as the build script "just builds" (it is not like cmake which actually inspects and looks for things) so you need to setup both the correct compiler and correct version. If you have visual studio installed the best way is to launch one of the "Visual Studio Command promts" (the corresponding with your target type (ie. x64, w32). Another option is to run the vcvarsall.bat script. But in short things like:

python -V
cl
ml
ml64 # (for x64)

Has to work out of the box or everything will fail...

Win32:

mkdir win32-build-folder
cd win32-build-folder
git clone https://github.com/mickem/nscp.git
# Currently this script is only in the 0.4.1 branch so you need to check that out before you continue.
cd nscp
git checkout 0.4.1
cd ..
nscp\build\python\fetchdeps.py --target win32 --cmake-config dist
cd dist
cmake -G "Visual Studio 8 2005" ../nscp
msbuild /p:Configuration=RelWithDebInfo NSCP.sln

x64:

mkdir x64-build-folder
cd x64-build-folder
git clone https://github.com/mickem/nscp.git
# Currently this script is only in the 0.4.1 branch so you need to check that out before you continue.
cd nscp
git checkout 0.4.1
cd ..
nscp\build\python\fetchdeps.py --target x64 --cmake-config dist
cd dist
cmake -G "Visual Studio 8 2005 Win64" ../nscp
msbuild /p:Configuration=RelWithDebInfo NSCP.sln

Setup folders and build environment

Since we will use separate folders for x64 and w32 we need to create them first.

set TARGET=c:\MyDependencyFoloder
set TARGET_w32=%TARGET%\w32
set TARGET_x32=%TARGET%\x64
mkdir %TARGET%
mkdir %TARGET_w32%
mkdir %TARGET_x64%

Hence fort all dependencies will be downloaded and uncompressed into BOTH these folders. Also note that you need to have different shells for each target architecture as well. Visual studio provides multiple "Command prompts" tagged with each architecture so make sure you are in the right one or these will fail.

Boost

Since boost dropped support for "filesystem2" in faviour of filesystem3 (which I have not migrated to yet) last ok version of boost is 1.49. I will try to upgrade to boost filesystem3 in the near future to resolve this.

Download URL: http://www.boost.org

Win32:

# Download and decompress into the following folder:
cd %TARGET_w32%\boost_1_49_0
bootstrap.bat
bjam --toolset=msvc-8.0 runtime-link=static

x64:

# Download and decompress into the following folder:
cd %TARGET_x64%\boost_1_49_0
bootstrap.bat
bjam --toolset=msvc-8.0 runtime-link=static address-model=64

OpenSSL

Openssl does not require anything special out of the box but there are a some tweaking in regards to masm and such which "can" be used. Also note that if you get "ml64 no such file..." errors you are in the wrong shell. You also need to clean out all temp folders if you were in the wrong shell as it does not rebuild otherwise.

Download URL: http://www.openssl.org

Win32:

# Download and decompress into the following folder:
cd %TARGET_w32%\openssl-1.0.1c
perl Configure VC-WIN32
ms\do_masm
nmake -f ms\ntdll.mak

x64:

# Download and decompress into the following folder:
cd %TARGET_x64%\openssl-1.0.1c
perl Configure VC-WIN64A
ms\do_win64a
nmake -f ms\ntdll.mak

Google protocol buffers

Google protocol buffers is a pain as they do not provide any way to build x64 out of the box and also has visual studio file in the wrong format (for me). Hence it requires some tweaking.

Download URL: http://code.google.com/p/protobuf/

Win32:

# Download and decompress into the following folder:
cd %TARGET_w32%\protobuf-2.4.1
# TODO Convert visual studio projects: python.exe cvt-msdev.py
msbuild vsprojects\protobuf.sln /p:Configuration=Release
msbuild vsprojects\protobuf.sln /p:Configuration=Debug

x64:

# Download and decompress into the following folder:
cd %TARGET_w32%\protobuf-2.4.1
# TODO Convert visual studio projects: python.exe cvt-msdev.py
# TODO: Apply x64 patch
msbuild vsprojects\protobuf.sln /p:Configuration=Release
msbuild vsprojects\protobuf.sln /p:Configuration=Debug

ZeroMQ

ZeroMQ is another one of these rather crappy projects with has no x64 version, no vs2005 projects and no support for debug builds. In short everything you can do wrong they have nailed it. Hence it requires some tweaking.

Download URL: http://www.zeromq.org

Win32:

# Download and decompress into the following folder:
cd %TARGET_w32%\zeromq-2.2.0
# TODO: Convert visual studio projects: python.exe cvt-msdev.py
# TODO: Apply debug patch
msbuild builds\msvc\msvc.sln /p:Configuration=Release
msbuild builds\msvc\msvc.sln /p:Configuration=Debug

x64:

# Download and decompress into the following folder:
cd %TARGET_w32%\zeromq-2.2.0
# TODO: Convert visual studio projects: python.exe cvt-msdev.py
# TODO: Apply debug patch
# TODO: Apply x64 patch
msbuild builds\msvc\msvc.sln /p:Configuration=Release
msbuild builds\msvc\msvc.sln /p:Configuration=Debug

Google break pad

Download URL: TODO

TODO

# Download and build google break pad
src\tools\gyp\gyp.bat src\client\windows\breakpad_client.gyp

# Download and install psdk into:  src\third_party\platformsdk_win7\files
# Apply patch for TokenStream (?)

msbuild src\client\windows\breakpad_client.sln /p:Configuration=Release /p:Platform=Win32
msbuild src\client\windows\breakpad_client.sln /p:Configuration=Debug /p:Platform=Win32

Lua

No build required simply download it into the various architecture folders.

Download URL: http://www.lua.org

TinyXML

No build required simply download it into the various architecture folders.

Download URL: https://github.com/leethomason/tinyxml2

Crypto++

No build required simply download it into the various architecture folders.

Download URL: http://www.cryptopp.com/

Building NSClient++

This is the easy one (yeah, right...). First think you need though is to configure all the paths to the various libraries you are using. To help with this here is an example of the build.cmake file I use:

IF(WIN32)
	if(CMAKE_CL_64)
		SET(LIBRARY_ROOT_FOLDER	"d:/source/x64")
	ELSE(CMAKE_CL_64)
		SET(LIBRARY_ROOT_FOLDER	"d:/source/w32")
	ENDIF(CMAKE_CL_64)

	# Setup boost
	set(Boost_USE_STATIC_LIBS		ON)
	set(Boost_USE_STATIC_RUNTIME	ON)
	set(BOOST_USE_MULTITHREADED		ON)
	SET(BOOST_ROOT "${LIBRARY_ROOT_FOLDER}/boost_1_49_0")
	SET(BOOST_LIBRARYDIR "${BOOST_ROOT}/stage/lib")

	# Tiny XML
	SET(TINYXML2_DIR "${LIBRARY_ROOT_FOLDER}/tinyxml2")

	# Python (python requires two installations to build bith versions)
	if(CMAKE_CL_64)
		SET(PYTHON_ROOT c:/python/27x64)
	ELSE(CMAKE_CL_64)
		SET(PYTHON_ROOT c:/python/27)
	ENDIF(CMAKE_CL_64)
	
	# Lua protocol buffers
	SET(PROTOC_GEN_LUA "C:/Python/27x64/Scripts/")
	
	# Google breakpad: TODO
	SET(BREAKPAD_ROOT "${LIBRARY_ROOT_FOLDER}/google-breakpad-svn")
		
	# Google protocol buffers
	#SET(PROTOBUF_LIBRARY_SUFFIX "-lite")
	#SET(PROTOBUF_LIBRARY_SUFFIX_DEBUG "-lite")
	SET(PROTOBUF_ROOT "${LIBRARY_ROOT_FOLDER}/protobuf-2.4.1")

	# OpenSSL
	#SET(OPENSSL_ROOT_DIR "${LIBRARY_ROOT_FOLDER}/openssl-1.0.1c")
	# Due to crappy defaul openssl script we need to set these...
	SET(OPENSSL_ROOT_DIR "${LIBRARY_ROOT_FOLDER}/openssl-1.0.1c/out32dll")
	SET(_OPENSSL_INCLUDEDIR "${LIBRARY_ROOT_FOLDER}/openssl-1.0.1c/include")
	
	# ZeroMQ
	SET(ZEROMQ_ROOT "${LIBRARY_ROOT_FOLDER}/zeromq-2.2.0")

	# Crypto++
	SET(CRYPTOPP_DIR "${LIBRARY_ROOT_FOLDER}/crypto++-5.6.1")

	# Lua
	SET(LUA_ROOT "${LIBRARY_ROOT_FOLDER}/lua-5.2.1")
ENDIF(WIN32)

After this you need to either edit and run the batch_build_win.bat script or do it manually which is what I will describe here.

Win32:

mkdir %TARGET_w32%\nscp
cd %TARGET_w32%\nscp
cmake -G "Visual Studio 8 2005" c:\WHERE\MY\SOURCE\IS
msbuild /p:Configuration=RelWithDebInfo NSCP.sln

x64:

mkdir %TARGET_x64%\nscp
cd %TARGET_x64%\nscp
cmake -G "Visual Studio 8 2005 Win64" c:\WHERE\MY\SOURCE\IS

And that's it!