Thursday, September 04, 2008

CVS Client commands for Linux

To Checkout Code

export CVS_RSH=ssh
cvs -z9 -d :ext:<user>@<cvsserver>:<repository> co <module name>

Thursday, August 07, 2008

Deployment of Applications Built with VC++ 2005

Deploying applications built with VC++ 2005 requires presence of particular libraries needed by Visual C++. This will also vary according to the target machine's operating system.

There are several options for the deployment:

  1. Use Visual C++ Redistributable Package
  2. Use the MSM merge modules
  3. Use Private Assembly



While the first two options respectfully require full installation of all libraries and presence of WinSxS assemblies (not present under all currently used operating systems), the third one can be used by copying only required libraries in the application directory. Furthermore, option 1) and 2) require administrative privileges.

The following libraries are required for option 3):

DLL Visual C++ Library
atl90.dll C Runtime and Standard C++ Libraries
msvcm90.dll
msvcp90.dll
msvcr90.dll
C Runtime and Standard C++ Libraries
mfc90.dll
mfc90u.dll
mfcm90.dll
mfcm90u.dll
mfcmifc90.dll
Microsoft Foundation Classes

Thursday, July 17, 2008

Lua - Scripting Language

More info on Lua available at About - Lua.

Here we will see how we can call lua script from C++. Code below is tested with VC2K5 EE with Lua 5.1.

#include

extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}

class Lua_State
{
lua_State *L;
public:
Lua_State() : L(lua_open()) { }

~Lua_State() {
lua_close(L);
}

// implicitly act as a lua_State pointer
inline operator lua_State*() {
return L;
}
};

static void open_libs(lua_State *L)
{
luaL_openlibs(L); // Lua 5.1 single call to load all libs
}

static int execute_program(lua_State *L)
{
// make a short function to make program behaviour more clear
return lua_pcall(L, 0, LUA_MULTRET, 0);
}

static void report_errors(lua_State *L, const int status)
{
if ( status!=0 ) {
std::cerr << "-- " << lua_tostring(L, -1) << std::endl;
lua_pop(L, 1); // remove error message
}
}

int main(int argc, char** argv)
{
for ( int n=1; n
Lua_State L;
open_libs(L);

int s = luaL_loadfile(L, argv[n]);

if ( s==0 )
s = execute_program(L);

report_errors(L, s);

// lua_close(L) automatically called here
}

int i;
std::cin >> i;
return 0;
}


Additional library required to build is luaX.Y.lib where X and Y refers to lua version. I had this as lua5.1.lib.

This is the simple way to use/call lua from C++. More useful/handy examples available at SampleCode.