3/20/2014

Build yajl in windows

I've used yajl, which is very attractive library for json in C.
Although, in package including a doc, 'BUILDING.win32', when I followed the guide, I've got some error.

First of all, I have no experience about CMake, and 'CMakeLists.txt' for window build, seems to have a little mistake.

For solving, let's say the path of 'yajl' package is 'D:\yajl_2_0_4_test'.
(My environment is CMake 2.6 and VS2010 for visual studio command prompt.)
In 'D:\yajl_2_0_4_test\CMakeLists.txt', below code have to append on line 14,
cmake_minimum_required(VERSION 2.6)

SET (YAJL_MAJOR 2)
SET (YAJL_MINOR 0)
SET (YAJL_MICRO 4)
By adding above code, I could acquire such a nice build log!








3/14/2014

Build time speed-up in VC++ project

There are some ways to improve VC++ project compile time.

Firstly, through using #pragma once directive and #ifdef guard. Although, #pragma once is not standard, it can be recognized in MS VC++ compiler. Furthermore, it does not try to open itself, whereas #ifdef guard opens header file once, and then, if the symbol is defined, not load.
However, when I apply #pragma once in my project, I couldn't find distinct different result. Before applying #pragma once, I was using #ifdef guard only, the build time was approximately 3 minute more. After applying that, although the build time was shortened about several seconds, I'm not sure if there was any chance.

Second method is forwarding declaration. It means, if you just use pointer or reference of class as a class member in your header file, you don't need to include the header file which is declared the class.

And using 'impl' pattern is another well-known method, but if goal is just decreasing compile time, it may be cumbersome work in terms of additional writing code.

First of all, to turn of '/MP' switch is the most fastest and simplest method to improve build speed. '/MP' means 'build with multiple processes. In vs2010, the MP switch is turn off in default because it conflicts /Gm(Enable Minimum Rebuild).
When I turned on /MP switch, my project's compile time was shortened over 3 minutes to under one minute.