Monday 6 May 2013

BYOD - Bring Your own device

What is BYOD, seem's absurd at the first time. When i heard it for the first time, i thought, may be the author wanted to write BODY, looks similar, anyways, coming to the point, what is BOYD, it actually is a new policy, adopted by many organisation's, that allow's the employees to bring their own personal devices in work environment for official purposes.

( Benefits of bring personal devices to work )
Most of us working in a corporate environment know very well that, personal mobile devices (laptop, smart phones, notepads etc), storage media devices etc, are strictly prohibited in the work environment. But, in reality how many of us have always followed this rule, actually very few of us. Many people install various software's on their office machines, though it is not permitted, because they are comfortable using these software's, than those provided by the organisation. This comfort results in increased productivity. More output, more profit, with less  time and effort. This sounds good right, employees are satisfied, organisation is earning profit.

( Losses )
 However, good things never come for free. Now lets see other side of the coin. As employees, install  software's that are not recommended,  bring their own devices in the organisational network, it creates a big loop hole in the security framework of the organisation. Making it more and more vulnerable to different types of attacks from external sources. Gradually the organisations understood that stopping this is not possible, hence this new term came into picture.

( BYOD to enhance the benefits )
As said earlier, stopping the employees from bringing personal devices at work is not possible. Hence, these organisations decided to allow the employees to do so, but under certain guidelines. This is called as BYOD policy. This can relax the organisation as well as keep the employees happy.

As BYOD programs become more commonplace, 38% companies expect to stop providing devices to workers by 2017, according to a global survey of CIOs by Gartner, a research firm.
Currently this concept is highly accepted by the american countries than that of european countries. However, apart from other benefits, if we think more widely, this will reduce the overall consumption of devices by the population, while serving its purpose. As there would be no need to buy 2 devices, 1 would be sufficient at the work place as well as at home. Hence, this approach if adopted by developing countries would be more beneficial.

Monday 18 March 2013

Compiling XALAN for win64

Compiling XALAN 1.10

Here i have assumed that you already have a xerces compiled with you in a 64bit version, if not please refer to my previous blog post.

I have divided the compilation process into 3 parts, for easy understanding,

Part I : This will help you to create the intial environment to compile xalan library.
Part II : This will help you to compile Xalan messages library, which is needed by the xalan library.
Part III : Finally compiling the xalan library is described in this part.

----------------------------------------------------------------------------------------------------------------
PART I : Creating the environment.
----------------------------------------------------------------------------------------------------------------
Step 0 : In the root directory of xerces (not the xalan root) make sure you have the following folders,
lib -> Containing x64 compiled xerces .lib file in this directory.
bin -> Containing x64 compiled xerces .dll file in this directory.
include -> Containing the header files of xerces in this directory.

The easiest way to get the header files is, get a prepackaged binary distribution and copy the include directory out of that.

Step 0.5 : Create a environment variable XERCESCROOT , set this to the root directory of xerces.
To create a environment variable on windows 7,
Press start, right click on Computer and select properties.
Then in that windows, in the left panel, click Advanced system properties.
Then “System Properties” window opens, Clik the Environment Variables button and click new.

Then a dialog box appears saying “New User Variable”
Set Variable name as XERCESCROOT

Set Variable value as <path to xerces root folder>

----------------------------------------------------------------------------------------------------------------
PART II : Compiling for Xalan Messages
----------------------------------------------------------------------------------------------------------------
Step 1 : Go to <xalan_src_dir>\c\Projects\Win32\VC7.1\Utils
Step 2 : Create a file compile.bat and open it in a editor and add the following lines.
set XERCESCROOT=<path to your xerces install dir>
cd Localization
nmake /f BuildMessages.mak BITS=Win64 CFG=Release TYPE=inmem LOCALE=en_US
cd ..
Step 3 : Open <xalan_src_dir>\c\Projects\Win32\VC7.1\Utils\MsgCreator\MsgCreator.mak in a text editor. This file has several sections, one for each supported configuration.
Find the appropriate section, identified by the following line:
!ELSEIF "$(CFG)" == "MsgCreator - Win64 Release"
In that section, edit the CPP_PROJ variable, which contains the compiler command line to update obsolete, nonexistent, and missing parameters passed to the compiler.
/GX becomes /EHsc (this has to do with exception handling

Delete /YX and /Fp params (precompiled header junk)
/ML becomes /MD (has to do with which C runtime to link to. xerces used /MD)
Add /Zc:wchar_t- to disable wchar_t as a built-in type.

Step 4 : Edit the LINK32_FLAGS variable and replace /machine:IA64 at the end of that line with /machine:x64.
In the same line find /machine:IX86 and change it to /machine:x86 close the file.

Step 5 : Open <xalan_src_dir>\c\Projects\Win32\VC7.1\Utils\XalanMsgLib\XalanMsgLib.mak in a text editor.
Find the appropriate section, identified by a line like:
!ELSEIF "$(CFG)" == "XalanMsgLib - Win64 Release"

In that section, edit the CPP_PROJ variable, which contains the compiler command line to update obsolete, nonexistent, and missing parameters.

/GX becomes /EHsc (this has to do with exception handling
Delete /YX and /Fp params (precompiled header junk)
/ML becomes /MD (has to do with which C runtime to link to. xerces used /MD)

Add /Zc:wchar_t- to disable wchar_t as a built-in type.

Step 6 : Edit the LINK32_FLAGS variable and replace /machine:IA64 at the end of that line with /machine:x64.
In the same line find /machine:IX86 ans change it to /machine:x86
close the file.

Step 7 : Open a MSVC x64 command prompt, and from there, run the batch file you created previously. It should run successfully, but with many warnings, similar those we got when building xerces. Note that the output goes to:

<xalan_src_dir>\c\Build\Win64\VC7.1\Release

In this folder you will find the “XalanMessages_1_10” .dll and .lib files.

----------------------------------------------------------------------------------------------------------------
PART III : Compiling the Xalan library.
----------------------------------------------------------------------------------------------------------------
Step 8 : Start VC (Visual Studio) and load the Xalan VC project from <xalan_src_dir>\c\Projects\Win32\VC7.1\Xalan.sln.

Step 9 : Let the IDE convert the project to whatever version your IDE is.

Create x64 configurations for all the projects. ( I assume you know this..)
The AllInOne project is the one which creates the library. In the project properties for that project, for x64 configuration, make the following changes:
- C/C++->General: change "Win32" to "Win64" in the last path under Additional Include Directories.
- C/C++->Output Files: change "Win32" in all the output paths to "Win64".
- C/C++->Language: disable wchar_t as an built-in type.
- Linker->General: change "Win32" in the Output File path to "Win64", and again in the last path listed under Additional Library Directories.
- Linker->Advanced: change "Win32" to "Win64" in the path under Import Library.
Step 10 : Now close the visual studio window and open the file <xalan_src_dir>\c\Projects\Win32\VC7.1\AllInOne\AllInOne.vcproj in a text editor.
Step 11: Find "Release|x64" configuration in the file, then under the same tag scroll down to “VCLinkerTool” tag, there is an "AdditionalOptions" attribute that says /MACHINE:1386, delete that attribute. Close the editor and load up the solution again.
Step 12 : It is also advisable to add two more preprocessor symbols to the project, otherwise you will get a *lot* of warning spam (i got 5477 warnings) about use of insecure functions, and the build will take a lot longer: _SCL_SECURE_NO_WARNINGS, _CRT_SECURE_NO_WARNINGS
You can put the above macros in C/C++ -> Preprocessor -> Preprocessor Definitions

Step 13 : Build the AllInOne project, right click AllInOne in the Solution Explorer pane,
click Project Only->Build Only AllInOne.

The libraries are written to,
<xalan_src_dir>\c\Build\Win64\VC7.1\Release.
----------------------------------------------------------------------------------------------------------------

Compiling XERCES for Win64

Compiling XERCES 2.7

What is xerces?

An XML DOM parser, XERCES provides functionality for parsing, generating, manipulating, and validating XML documents. Xerces-C++ is faithful to the XML 1.0 and 1.1 recommendations and many associated standards.

Dowload Site :

You can find the binaries and source of all the versions from here.

Compiling XERCES 2.7 for x64 bit machines on windows.

Step 1: Open xerceesroot\Projects\Win32\VC7.1\xercer-all\xerces-all.sln in visual studio.

Step 2: Create a x64 bit configuration in visual studio.
Confirm that in Linker->Advanced->Target Machine it say Machine64

Step 3: Now close the visual studio window and open the file xerceesroot\Projects\Win32\VC7.1\xercer-all\XercesLib\XercesLib.vcproj in a editor.

Step 4: Find "Release|x64" then scroll down to “VCLinkerTool”, there is an AdditionalOptions attribute that says /MACHINE:1386, detele that attribute. Close the editor and load up the solution again.

Step 5: Next go to properties->C/C++->Preprocessor->Preprocessor Definitions add WIN64 preprocessor symbol.

Step 6: Change the wchar_t setting in properties->C/C++->Language->Treat wxhar_t as Built-inType to No (/Zc:wchar_t-)

Step 7: Right click the XercesLib project and select Project Only->Build Only XercisLib.

You will find the compiled x64 binaries at the following path,


<path to xerces root>\Build\Win32\VC7.1\Release\

Tuesday 5 March 2013

Compiling libgcrypt for win64

After a long search for how to compile libgcrypt for win64, i found a solution to do so, and here i would like to share it,

libgpg-error also needs to be build to successfully compile libgcrypt. Hence we also compile libgpg-error here.
Both the libraries can be downloaded from here.
Before compiling in 64 bit you will need to get familiar with few tools,
MinGW-64 and MYSYS: These are necessary to compile the libgcrypt library.

-------------------------------------------------------------------------------------------------------------------
R E Q U I R E D  T O O L S
-------------------------------------------------------------------------------------------------------------------

MinGW-w64

It is necessary to have mingw32 on the machine to sucessfullly compile libgcrypt.
MinGW-w64 provides GNU compiler collection (GCC) and GNu Binutils, for the use in the development of native microsoft windows applicaiton.

Download Site : http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Automated%20Builds/

Step 1:
Download the zip version of the file, for windows, and not the .tar.bz2 version.
I had downloaded "mingw-w64-bin_i686-mingw_20111220.zip".

Step 2:
Extract it to a folder, i had extracted the file to "c:\mingw".
-------------------------------------------------------------------------------------------------------------------

MSYS

MSYS is a collection of GNU utilities such as bash, make, gawk and grep to allow building of applications and programs which depend on traditionally UNIX tools to be present.

Download Site: http://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20%28Win64%20hosted%29/MSYS%20%2832-bit%29/

Though i will refer the installation steps here, you can find the installation inforamtion at the below link. http://sourceforge.net/apps/trac/mingw-w64/wiki/MSYS

Step 1: Download the MSYS-xxxxxxxx.zip file, do not download the source code.
I had downloaded the MSYS-20111123.zip file.
Step 2: Extract the file, i had extracted the file in "c:\msys".
Step 3: Go to "c:\mysys" and doubleclick msys.bat file.
Step 4: Type: sh /postinstall/pi.sh
It will ask do you want to continue with post install , press 'y' and then 'enter' key.
Then it will ask, "Do you have MinGW installed?", press 'n' and the 'enter' key.
Press "ENTER" to continue the process.
Step 5: Type: mount (path to mingw) /mingw
I had typed, mount c:\\mingw /mingw

This will mount our mingw directory at /mingw, the path variable is already set to /mingw/bin
just make sure you have the binaries in "c:\mingw\bin"

-------------------------------------------------------------------------------------------------------------------
C O M P I L A T I O N  S T E P S
-------------------------------------------------------------------------------------------------------------------

First we will compile libgpg-error.

Step 1: Extract the downloaded libgpg-error library to a folder.
Step 2: Open the MSYS terminal ("c:\\msys\msys.bat") and use cd command to go to the directory where you extracted it.
Step 3: ./configure --host=x86_64-w64-mingw32 --prefix=path_to_installation directory
I had used:
./configure --host=x86_64-w64-mingw32 --prefix=/home/newUser/installDir/
After sucessful compilation, we find the binaries in the directory specified by --prefix.

Step 4: Now type: make install
This should make the library and put it in the folder specified by --prefix specified in the ./configure
-------------------------------------------------------------------------------------------------------------------

Compiling libgcrypt:

Step 1: Extract the downloaded libgcrypt library
Step 2: Open the MSYS terminal ("c:\\msys\msys.bat") and cd to where you extracted it.
Step 3: ./configure --host=x86_64-w64-mingw32 --prefix=<whatever> --with-gpg-error-prefix=<dir where you installed libgpg-error> --disable-asm
I had used:
./configure --host=x86_64-w64-mingw32 --prefix=/home/newUser/installDir/ --disable-asm

After sucessful compilation, we find the binaries in the directory specified by –prefix.

Step 4: Now type: make install
This should make the library and put it in the folder specified by --prefix specified in the ./configure
Note that i have used the same installation directory to install libgpg-error and libgcrypt.

I have yet not successfully tested each functionality of the library, but i hope it works fine, and note that after compiling libgcrypt library you will find a .dll.a file in lib folder which is present in the directory where you installed the library (the path you had provided to --prefix option while running configure command)

This .dll.a is actually the .lib file of the dynamic library.
The installation directory/bin will contain the .dll files of the library.
-------------------------------------------------------------------------------------------------------------------

Explore more, learn more.... ;)