Popular Posts

Total Pageviews

Wednesday, July 6, 2011

inclusion of new files into patch and creation of patch on linux

Programmer who take part in some kind of big code needs to generate patch files. Begginers do get trouble here as how to create, there is simpple command on linux diff use that as follows
Suppose u have old code in oldmake folder and new code in home/newmake. Then follow these steps.
1. cd home
2. diff -urN /home/waste/oldmake newmake > patch1
Now you might have written some new file instead of modifying any file. There is no need to worry diff is already taken care of that stuff, your patch includes those files.

How to use patch
if you want to apply patch inside /home/checkmake then go to checkmake folder
1. cd /home/checkmake
2. patch -p patch1

Tuesday, June 28, 2011

ns2 installation, problems and solutions on fedora

One of the most easiest way to install ns2 is to download ns-allinone package. So download ns-allinone-2.34.tar.gz. now follow these steps.
1. go to directory where you saved tar.gz file and execute following command
tar -xzf ns-allinone-2.34.tar.gz
2. cd ns-allinone-2.34/
3. now install the package using (switct to root or use sudo)
./install
4. first problem you encounter is "g++ command not found" otherwise skip this step
soln- yum install gcc-g++
now try 3rd step again
5. you might encounter problem of "/home/user.../generic/tk.h:557: error expected declaration specifiers or '...' before 'Window' and similar other errors while installing tk (otherwise skip this step)
soln- yum install libX11-devel
now try 3rd step
6. if you get "can't find X includeds otcl-1.13 configuration failed! Exiting.."
soln- yum install libXt-devel or yum groupinstall "X Software Development" later one is better.
now try 3rd step and it will run successfully

Friday, June 17, 2011

using binary number in C or C++

Many C learner face the problem of initializing a variable with binary value or assign a integer variable with binary values. Don't worry its very easy as described in C you can use 0x for hex, 0 for octal similarly 0b defines binary. for example if you want to assign binary 1101 (i.e 13) to variable. then use this
int var = 0b1101;

Thursday, June 16, 2011

undefined reference to static variable in c++

Suppose i have a code which need to reference static variable
so we have following code in trial.h
class Trial
{
static int v;
void setCode();
}

in trail.cc
#include "trial.h"
void Trial::setCode()
{
v=1;
}

This above code will give undefined reference to Trial::v error. To remove this error either remove static word from v in .h file or if it is necessary to have static word. then do as following.
in trial.cc
#include "trial.h"
int Trial::v;
void Trial::setCode()
{
v=1;
}

now your error is gone . happy coding