Thứ Năm, 2 tháng 1, 2014

PATH: all you need to know

Hi all,
Previously, I write a blog about LD_LIBRARY_PATH [1]. Continuing this series, I write this blog about another important environment variable in Linux which is PATH.
PATH is the environment that contains paths to executable files. For example, /home/tranlaman/bin, /usr/local/sbin, /usr/local/bin/, /usr/sbin, or /bin.
Otherwise, LD_LIBRARY_PATH contains dynamic library for other programs.

MATLAB options file in Linux 64

Happy new year 2014,
I am writing this blog to notice you a trick to change option files in Matlab in Linux, which is very useful. When you want to use MEX to compile a C/Fortran source in MEX interface, you need to modify option files mexopts.sh in Linux because the default file contains errors in Linux. Why is it important so? The answer is that options files control which compiler to use, the compiler and link command options, and the runtime libraries to link against.
Then, where the file locate in Linux? The default file mexopts.sh locates in /home/tranlaman/.matlab/R2012a. But there is another default root file lie in /home/tranlaman/MATLAB/R2012a/bin which overrides the file in /home/tranlaman/.matlab/R2012a. So, modifying the mexopts.sh in /home/tranlaman/MATLAB/R2012a/bin would change everything.
Finally, how do we modify this file? The answer is to change some compiling and linking flag such as CC, CFLAGS, CLIBS, LD, LDFLAGS. Please refer to [1] as a complete flag for custom building MEX files.
Wish everyone has a good year.

Thứ Sáu, 20 tháng 12, 2013

HOW-TO: Making an icon licking in Ubuntu

Hi all,
After a while of using Ubuntu, I feel that everything is fine and cool. It is still something missing in Windows. They are icons. This tutorial guides you how to make an icon licking in Ubuntu. I prefer to style of learning by doing, so let start with an example.
Let save the following code in a file named matlab.desktop, and move it to /usr/share/applications. It is a system folders, and you should know that we need to use sudo.
#!/usr/bin/env xdg-open
[Desktop Entry]
Type=Application
Icon=/usr/share/icons/matlab_logo.gif
Name=MATLAB R2012a
Comment=Start MATLAB - The Language of Technical Computing
Exec=matlab -desktop
Categories=Development;

All you need to do is to replace a command to start your application, in this case, it is MATLAB R2012a. It should be noticed that excutable command here is that matlab. We need to create alias for matlab.
 cd /usr/local/bin/ 
 sudo ln -s /usr/local/MATLAB/R2012a/bin/matlab matlab
This trick will allow you to start Matlab from any folder, as you were trying to do. Further, you should replace icon with your logo. That's all. Then, you find an icon of Matlab in /usr/share/applications. Now you can search Matlab in Launcher Utility and send this icon to Desktop to have a licking icon such that in Windows.

I know that I need to create some icons for some applications I like since a long  time ago. But I rely on the reason that I am busy so I did not care about it. Now I change. Let work with a style, live with a style and more,  research also with a style. I am gonna figure out what style I am.
Thanks,

Chủ Nhật, 24 tháng 11, 2013

Wordle - a new toy

Hi,
After a long time, I did not write anything on my blog. I am quite busy with the modules in uni and other stuff in Computer Vision and Machine Learning. When surfing around for some papers and dissertation, I found a new toy for undergrads, grads student or some geeks. When you finished writing something such as reports, papers and theses, you want to visualize your work just in some words according to their prominence in the writing. Wordle is your toy. Wordle will visualize most frequent  words, "cloud words", that appear in the provided text.
http://www.wordle.net/
The following is the wordle of one of my final review paper.

Chủ Nhật, 14 tháng 7, 2013

LINUX: Awesome error

Today, I met an awesome error when running a shell script file in Ubuntu.
tranlaman@tranlaman-VirtualBox:~/Desktop/workspace/partapp-r2$ ./run_partapp.sh bash: ./run_partapp.sh: /bin/sh^M: bad interpreter: No such file or directory
 The following link can fix the problem excellently:
http://www.gizmola.com/blog/archives/87-linux-shell-scripting-bad-interpreter-no-such-file-or-directory.html

Reason: Because the code was developed in Mac or somewhere, then I run it in Ubuntu. The file format is different.

Thứ Năm, 11 tháng 7, 2013

LD_LIBRARY_PATH all you need to know.

Hi all,
I have spent countless hour when trying to compile the C/C++ code in Linux (Ubuntu 12.04) using GCC or G++ compiler. I met a bunch of errors and then I figured out in Ubuntu the options -I -L and LD_LIBRARY_PATH are quite important. I read README and do exactly the same but still met the errors. Consequently, it is going to save your time if you understand a little bit about -I option, -L options and LD_LIBRARY_PATH.
-I (Include) specifies the directories of included headers file needed to compile your code, for example, the #include <xxx.h>
- L (Library) specifies the directories of shared libraries or static libraries for linking. It is used with -l (not number but an alphabet) options to specify the lib name. For example, a library is libxxx.so or libxxx.a would have -l option as -lxxx.
LD_LIBRARY_PATH (LinkDynamic Library Path -- I guess :-D) specifies the directories of shared libraries for linker during the run-time [2]. Also, it is used at the link-time, when linker looks for libraries and resolve external symbols in these directories. The problems are raised because of LD_LIBRARY_PATH since the directories at the link-time and run-time are different [3]. Some issues relate to incompatible versions of required libraries.
Refer to the links bellow for hands-on errors and solutions:
* The difference between -I and -L options:
[1] http://adf.ly/Rsfwr/what-is-the-difference-between-i-and-l-in-makefile
* The difference between LD_LIBRARY_PATH and -L at the run-time:
[2] http://adf.ly/RsgVz/what-is-the-difference-between-ld-library-path-and-l-at-link-time
* Why the LD_LIBRARY_PATH is bad?
[3] http://adf.ly/RskIY/UnixResource_dir/_/ldpath.html

Thứ Bảy, 15 tháng 6, 2013

Question: Where does my program reside if I install a program in Ubuntu?

Answer:
Normally, it would go to /usr/local. In /usr/local, you would have subdirectories such as /bin, /etc, /lib, /share, /src. These sub-folders contain appropriate files depending on the type of program that you want to install.