Today I found it's nice to work with ctags, which is a source code analysis tool.
Although it doesn't have a nice front-end gui interface, ctags works nicely with vi and vi's brothers, e.g., vim, gvim.
The source navigator is also nice to try, but it looks much complicated when you just want to have a look at the classes or functions in your code. The other important thing is I am used to program in GVIM.
The way to use ctags is very simple, first go to your source directory, and type following command in your terminal:
ctags -R *
this command will generate a tags file which you can find in your source directory.
Next thing is using vi or gvim to open your source file, and move cursor to the keyword, e.g, class name, function name, etc., and use CTRL-] to get this keyword's source position. If you want to get backward, then use CTRL-T.
CTAGS is small and big enough for me.
Showing posts with label LinuxProgram. Show all posts
Showing posts with label LinuxProgram. Show all posts
Monday, April 18, 2011
Wednesday, March 3, 2010
The errors and solutions when compiling the levmar with lapack
Well, there are a lot of errors. I google a lot to find solutions, and I add them here. Good for newbies.
Q1. undefined reference to `MAIN__'
S: add '-u MAIN_' in the GCC part of Makefile
Q2. undefined symbol: _gfortran_concat_string
S: add '-gfortran' in the GCC part of Makefile
Q3. misuse the command matlab mex with the command mex from pdfTeXK.
S: replace 'mex' by whole directory '/where your matlab is/bin/mex' in Makefile
Q4. multiple definition of `xerbla_'
S: set 'LAPACKBLASLIBS_PATH=/usr/lib/atlas' in the Makefile of matlab subfolder
Q1. undefined reference to `MAIN__'
S: add '-u MAIN_' in the GCC part of Makefile
Q2. undefined symbol: _gfortran_concat_string
S: add '-gfortran' in the GCC part of Makefile
Q3. misuse the command matlab mex with the command mex from pdfTeXK.
S: replace 'mex' by whole directory '/where your matlab is/bin/mex' in Makefile
Q4. multiple definition of `xerbla_'
S: set 'LAPACKBLASLIBS_PATH=/usr/lib/atlas' in the Makefile of matlab subfolder
Tuesday, January 20, 2009
Multi-threads program
Before I always think Multi-thread program is difficult and a little bit huge !^_^
Today I realize one simple parallelize program by two threads.Although it did not fulfill my idea,but it do I told it..
That's not so difficult to know what's the multi-thread and write a simple example program..
Yes it's still huge because it want to do more work and fulfill more ideas. But for me or some task ,,we just need one pieces of it..So dont fear any more ..
Fear is because you know nothing about it..Just sit down and concentrate to read books and google. Then you will find it's not so difficult to do it like other guys..
Here is a very nice tutorial about pthreads.
http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html
Ps:Under linux c++, you can not define function like void* function(). Maybe you can do it in c language under c compiler. But for c++, GCC or G++ will give you wrong information about the function's parameter. I solved it by define function like void* function(void * p);
Here p is no used but you do need it to compile your program...
Today I realize one simple parallelize program by two threads.Although it did not fulfill my idea,but it do I told it..
That's not so difficult to know what's the multi-thread and write a simple example program..
Yes it's still huge because it want to do more work and fulfill more ideas. But for me or some task ,,we just need one pieces of it..So dont fear any more ..
Fear is because you know nothing about it..Just sit down and concentrate to read books and google. Then you will find it's not so difficult to do it like other guys..
Here is a very nice tutorial about pthreads.
http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html
Ps:Under linux c++, you can not define function like void* function(). Maybe you can do it in c language under c compiler. But for c++, GCC or G++ will give you wrong information about the function's parameter. I solved it by define function like void* function(void * p);
Here p is no used but you do need it to compile your program...
Wednesday, January 7, 2009
Solve the problem : stack overflow
I am a poor guy in computer programming.
Today when I run a recursive loop , my program crash!! It told me: stack overflow!
Why??
If I use Vagrind to check memory leak, it seems like no more memory can be added to this stack.
I have thought the memory of my computer is so big that it can not crash like this. But ....it happens as, when I run a program ,the complier will tell computer how much space this program need . If it need more ,then stack crash .
To solve this problem:
1, make the size of stack bigger..
2, change the method to decrease the program space .
I choose 2th method..Then I find the solution:
2.1,change the recursion to iteration
2.2,change the recursion to tail recursion
As I use the tree recursion , one function will call itself many times in its loop. For every call, the stack will save the path to parent function call , and save the local variable .
I find my program maybe difficult to be changed to iteration or tail recursion(it will wrong as I can not return for every function).
So the only choice might be elimination the local variable..Then I use more function and input parameters instead of using local variable..
Finally, for this ,it works...and become faster....It help me to do many works ,like region grow ,label connect component and morphological algorithm..
For more information:
http://triton.towson.edu/~akayabas/COSC455_Spring2000/Recursion_Iteration.htm
http://www.refactoring.com/catalog/replaceRecursionWithIteration.html
http://www.unc.edu/courses/2005spring/comp/120/001/handouts.html
Today when I run a recursive loop , my program crash!! It told me: stack overflow!
Why??
If I use Vagrind to check memory leak, it seems like no more memory can be added to this stack.
I have thought the memory of my computer is so big that it can not crash like this. But ....it happens as, when I run a program ,the complier will tell computer how much space this program need . If it need more ,then stack crash .
To solve this problem:
1, make the size of stack bigger..
2, change the method to decrease the program space .
I choose 2th method..Then I find the solution:
2.1,change the recursion to iteration
2.2,change the recursion to tail recursion
As I use the tree recursion , one function will call itself many times in its loop. For every call, the stack will save the path to parent function call , and save the local variable .
I find my program maybe difficult to be changed to iteration or tail recursion(it will wrong as I can not return for every function).
So the only choice might be elimination the local variable..Then I use more function and input parameters instead of using local variable..
Finally, for this ,it works...and become faster....It help me to do many works ,like region grow ,label connect component and morphological algorithm..
For more information:
http://triton.towson.edu/~akayabas/COSC455_Spring2000/Recursion_Iteration.htm
http://www.refactoring.com/catalog/replaceRecursionWithIteration.html
http://www.unc.edu/courses/2005spring/comp/120/001/handouts.html
Friday, September 5, 2008
Linker and compiler
In the Makefile, if you want to get object file ,you just need headfile and cpp file. If you build the execute file ,you should add lib files .
Wednesday, July 23, 2008
How to copy and manage other computer by shell on linux?
If you want to use your computer to do program work under other computer , you can do :
ssl -l yourUserName otherComputer'sIP
If you want copy one file to other computer by internet, you can:
scp fileNameWhichYouWantToCopy userName@otherComputer'sIP:/home/YOURDirectory
I learn it from a beautiful PhD girl....^_^
ssl -l yourUserName otherComputer'sIP
If you want copy one file to other computer by internet, you can:
scp fileNameWhichYouWantToCopy userName@otherComputer'sIP:/home/YOURDirectory
I learn it from a beautiful PhD girl....^_^
Monday, June 16, 2008
If you range the data by the loop in C++
Rember that it 's a wrong way to do this like:
Increase range:
for(int i=0;i<100;i++)
{ int x=a[i] ;
for(int j=i+1;j<100;j++)
{ int y=a[j];
if(y<x)
{ int t=a[j];a[j]=a[i];a[i]=t;}
}
}
Why that's wrong??
The reason is a[i] in the loop has been changed, but the x isn't changed. so It's wrong !
you can do it correctly like:
for(int i=0;i<100;i++)
{
for(int j=i+1;j<100;j++)
{ int x=a[i] ;
int y=a[j];
if(y<x)
{ int t=a[j];a[j]=a[i];a[i]=t;}
}
}
or
for(int i=0;i<100;i++)
{ int x=a[i] ;
for(int j=i+1;j<100;j++)
{
int y=a[j];
if(y<x)
{ x=y; int t=a[j];a[j]=a[i];a[i]=t;}
}
}
Increase range:
for(int i=0;i<100;i++)
{ int x=a[i] ;
for(int j=i+1;j<100;j++)
{ int y=a[j];
if(y<x)
{ int t=a[j];a[j]=a[i];a[i]=t;}
}
}
Why that's wrong??
The reason is a[i] in the loop has been changed, but the x isn't changed. so It's wrong !
you can do it correctly like:
for(int i=0;i<100;i++)
{
for(int j=i+1;j<100;j++)
{ int x=a[i] ;
int y=a[j];
if(y<x)
{ int t=a[j];a[j]=a[i];a[i]=t;}
}
}
or
for(int i=0;i<100;i++)
{ int x=a[i] ;
for(int j=i+1;j<100;j++)
{
int y=a[j];
if(y<x)
{ x=y; int t=a[j];a[j]=a[i];a[i]=t;}
}
}
Friday, June 13, 2008
How to match pair of braces in gvim??
you can use % to find a pair of {} or () // etc.....
see more :http://www.moolenaar.net/habits.html
see more :http://www.moolenaar.net/habits.html
Tuesday, May 27, 2008
How to find magic number in pnm or pgm images...???
A simple way, you can use vi or cat to see the image 's head file...
But I also try using the "identify", it gives me some image informations. Unfortunately, that's not what I want...
But I also try using the "identify", it gives me some image informations. Unfortunately, that's not what I want...
Static, Shared Dynamic and Loadable Linux Libraries
There are two kinds of library in Linux:
static library(.a) and dynamic library(.so)
The difference between them is
1, static library will link with and become a part of application. But the dynamic library just be used when compile and tied to application.
2, Many setup can use a same dynamic library at a same time. But linux just load them once.
3, You can load,unload and link dynamically library with application by system function
How to build the static library:
ar -cvq libliutest.a cliutest1.o cliutest2.o
List it:
ar -t libcliutest.a
Link it:
- cc -o myprogram progLiu.c libcliutest.a
- cc -o myprogram progLiu.c -L/path/to/library-directory -lcliutest
How to build the dynamically library:
gcc -Wall -fPIC -c *.c
gcc -shared -Wl,-soname,libcliutest.so.1 -o libcliutest.so.1.0 *.o
mv libliuctest.so.1.0 /opt/lib
ln -sf /opt/lib/libcliutest.so.1.0 /opt/lib/libcliutest.so
ln -sf /opt/lib/libcliutest.so.1.0 /opt/lib/libcliutest.so.1
see more website:"http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html"How to set gvim format for programming?
1,syntax on; It will make your gvim window seems more colorful;
2,set cindent; It will make your programming in c style;
3,set shiftwidth=4; It will set the distance between two level sentences.
2,set cindent; It will make your programming in c style;
3,set shiftwidth=4; It will set the distance between two level sentences.
Subscribe to:
Posts (Atom)