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