Build NSCP
This is a quick guide on how to build NSCP (NCSlient++) for your self. It is an embryo at the moment and will hopefully grow more into a real proper guide.
To begin with there are a few things you will need to build NSCP.
- boost (only needed for Eventlog, CheckDisk and CheckWMI)
- openssl (only needed for NRPE modules)
- Perl (open SSL requires this)
- A C++ compiler (I use Visual Studio 2005)
- stl (shipps with MSVC nowdays)
- boost build (either from boost or separately)
0, Get the source
Get the source: Th source is avalible via anonymous SVN from here:
svn co http://svn.nsclient.org/nscp/trunk
1, Setup environment
First we setup the environment, this is an "optional" step but I prefer it as it is simpler, all "directories" are configure here instead of all over the place. For updates check out the env.bat file found in the root of NSClient++
# ##################################################### # # setup environment set TARGET_DIR=d:\source\ set SOURCE_DIR=d:\source\libs-c\ set TOOLS_DIR=d:\source\tools\ set TARGET_LIB_DIR=%TARGET_DIR%\lib set TARGET_LIB_x86_DIR=%TARGET_LIB_DIR%\x86 set TARGET_LIB_x64_DIR=%TARGET_LIB_DIR%\x64 set TARGET_LIB_ia64_DIR=%TARGET_LIB_DIR%\ia64 set TARGET_INC_DIR=%TARGET_DIR%\include set PATH=%PATH%;%TOOLS_DIR%
2, boost
Boost ( http://www.boost.org) is required if you want to use CheckEventLog, CheckDisk and/or CheckWMI. The dependency can be disable via a compiler (NO_BOOST_DEP) flag and all you loose is the regular expression support. Below are commands for building for all platforms if you dont want that just use the segment you need.
# #####################################################
#Get Boost
#Get bjam and make sure it is in your path (tools dir)
# Build boost:
cd %SOURCE_DIR%
cd boost_1_39_0
#
# w32
#
%jam% --toolset=msvc --prefix=%TARGET_DIR% --includedir=%TARGET_INC_DIR% --libdir=%TARGET_LIB_x86_DIR%
runtime-link=static clean
%jam% --toolset=msvc --prefix=%TARGET_DIR% --includedir=%TARGET_INC_DIR% --libdir=%TARGET_LIB_x86_DIR%
runtime-link=static install
#
# all (for some reason boost places things "wrong" so we have to copy it right)
#
xcopy /s %TARGET_INC_DIR%\boost-1_39\*.* %TARGET_INC_DIR%
#
# x64 (amd64/EMT)
#
%jam% --toolset=msvc --prefix=%TARGET_DIR% --includedir=%TARGET_INC_DIR% --libdir=%TARGET_LIB_x64_DIR%
address-model=64 runtime-link=static clean
%jam% --toolset=msvc --prefix=%TARGET_DIR% --includedir=%TARGET_INC_DIR% --libdir=%TARGET_LIB_x64_DIR%
address-model=64 runtime-link=static install
#
# ia64 (Itanium)
#
%jam% --toolset=msvc --prefix=%TARGET_DIR% --includedir=%TARGET_INC_DIR% --libdir=%TARGET_LIB_ia64_DIR%
runtime-link=static address-model=64 architecture=ia64 clean
%jam% --toolset=msvc --prefix=%TARGET_DIR% --includedir=%TARGET_INC_DIR% --libdir=%TARGET_LIB_ia64_DIR%
runtime-link=static address-model=64 architecture=ia64 install
3, OPENSSL
Then we have openssl (required for encryption) and the only module that uses this is NRPEClient. Get openssl from openssl ( http://www.openssl.org) and again this is for all plattforms so just use the one(s) you need. There is a slight manual option here as iI dont know how to generate makefiles for /mt so for now you have to manually edit the makefile changing /MD to /MT)
# ##################################################### # get openssl: # get perl: cd %SOURCE_DIR% cd openssl-0.9.8k # # w32 # perl Configure VC-WIN32 ms\do_masm ## <<edit ms\nt.mak and change the compiler option from MD to MT>> nmake -f ms\nt.mak clean nmake -f ms\nt.mak nmake -f ms\nt.mak install xcopy /Y out32\*.lib %TARGET_LIB_x86_DIR% xcopy /s inc32\*.* %TARGET_INC_DIR% # # w64 (AMD64/EMT) # perl Configure VC-WIN64A ms\do_win64a nmake -f ms\nt.mak clean nmake -f ms\nt.mak nmake -f ms\nt.mak install copy out32\*.lib %TARGET_LIB_x64_DIR% # # ia64 (Itanium) # perl Configure VC-WIN64I ms\do_win64i ## <<edit ms\nt.mak and change the compiler option from MD to MT>> nmake -f ms\nt.mak clean nmake -f ms\nt.mak nmake -f ms\nt.mak install copy out32\*.lib %TARGET_LIB_ia64_DIR%
4, NSClient++
NSClient++ uses boost build to build and once you have that setup it should not be to hard to build. Since I use a lot of paths and what not I define them all inside the env.bat file but you can if you prefer use it all on the command line. The basic command for building NSClient++ is:
%jam% --toolset=msvc build-binaries
This will (though) not use any of the additional dependencies so it will be a less-then-ideal version of the program lacking many features. The full command (which I use is the following):
%jam% --toolset=msvc --with-lua=%LUA_SOURCE% --with-openssl --with-boost runtime-link=static variant=release address-model=32
--library-path="%TARGET_LIB_x86_DIR%" --with-psdk-lib=%"PLATTFORM_SDK_LIB_x86%" --with-psdk="%PLATTFORM_SDK_INCLUDE%"
--wix="%WIX_PATH%" build-binaries
For simplicity I have included 3 bat files:
- env.bat (Defines all paths)
- release-build.bat Builds both x86 and x64 version.
- build.bat builds:
- binaries
- archives (zippped files)
- installer (msi files)
So you could (if env.bat is setup) just go ahead and run:
release-build.bat







