Erlang shell .

commandline session

$erl
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [async-threads:0] [kernel-poll:false]

Eshell V5.9.1  (abort with ^G)
1> q().
ok
2> $
$erl
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [async-threads:0] [kernel-poll:false]

Eshell V5.9.1  (abort with ^G)
1> h().
ok
2> h()
2> .
1: h()
-> ok
ok
3> pwd().
/home/jeffrin/Downloads
ok
4> cd("..").
/home/jeffrin
ok
5> 1+2.
3
6> 3*2.
6
7> 3-3.
0
8> 6-2
8> .
4
9> 2*v(6).
12
10> math:pi().
3.1415921003589793
11> math:sin(10).
-0.5440211108893698
12> 21
12> 12e23
12> 2*v(12).
* 2: syntax error before: 12
12> k=1.
** exception error: no match of right hand side value 1
13> k=1
13> k
13> .
* 2: syntax error before: k
13> k.
k
14> K=1.
1
15> K.
1
16> K=K+1.
** exception error: no match of right hand side value 2
17> K=K.
1
18> P=2.
2
19> K+P.
3
20> b().
K = 1
P = 2
ok
21> f().
ok
22> b().
ok
23>

GCC COMMANDLINE OPTIONS PART 7

commandline session

$gcc -v main.c
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-4' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-4)
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1 -quiet -v -imultiarch x86_64-linux-gnu main.c -quiet -dumpbase main.c -mtune=generic -march=x86-64 -auxbase main -version -o /tmp/cc6KHWV5.s
GNU C (Debian 4.7.2-4) version 4.7.2 (x86_64-linux-gnu)
	compiled by GNU C version 4.7.2, GMP version 5.0.5, MPFR version 3.1.0-p10, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include  search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/4.7/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C (Debian 4.7.2-4) version 4.7.2 (x86_64-linux-gnu)
	compiled by GNU C version 4.7.2, GMP version 5.0.5, MPFR version 3.1.0-p10, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: c5f63dedeacd449634699df94fe3d914
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64'
 as -v --64 -o /tmp/ccw9UtSZ.o /tmp/cc6KHWV5.s
GNU assembler version 2.22 (x86_64-linux-gnu) using BFD version (GNU Binutils for Debian) 2.22
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.7/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.7/collect2 --sysroot=/ --build-id --no-add-needed --eh-frame-hdr -m elf_x86_64 --hash-style=both -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.7/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.7 -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.7/../../.. /tmp/ccw9UtSZ.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.7/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crtn.o
$

GCC COMMANDLINE OPTIONS PART 6

commandline session

$ gcc -c -Wall -Werror -fPIC main.c
main.c: In function ‘main’:
main.c:8:10: error: ‘i’ is used uninitialized in this function [-Werror=uninitialized]
cc1: all warnings being treated as errors
$vim main.c
$cat main.c
#include<stdio.h>
#include<math.h>

int main(void)
{
   float y;
   printf("n The Geek Stuff [%d]n", i);
   y=sinf(2.5);
   printf("%fn",y);
   return 0;
}
$ gcc -c -Wall -Werror -fPIC main.c
main.c: In function ‘main’:
main.c:7:39: error: ‘i’ undeclared (first use in this function)
main.c:7:39: note: each undeclared identifier is reported only once for each function it appears in
$vim main.c
$cat main.c
#include
#include

int main(void)
{
 int i=0;
   float y;
   printf("n The Geek Stuff [%d]n", i);
   y=sinf(2.5);
   printf("%fn",y);
   return 0;
}
$ gcc -c -Wall -Werror -fPIC main.c
$ls main.o
main.o
$rm main.o
$ gcc -c -Wall -Werror -fPIC main.c
$ls main.o
main.o
$gcc -shared -o libmain.so main.o
$ldd libmain.so
	linux-vdso.so.1 =>  (0x00007fffbbc64000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f74b1bfe000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f74b21b4000)
$

GCC COMMANDLINE OPTIONS PART 5

commandline session

$cat main.c
#include<stdio.h>
#include<math.h>

int main(void)
{
   int i;
   float y;
   printf("n The Geek Stuff [%d]n", i);
   y=sinf(2.5);
   printf("%fn",y);
   return 0;
}
$gcc main.c
$./a.out

 The Geek Stuff [0]
0.598472
$gcc main.c -lmath
/usr/bin/ld: cannot find -lmath
collect2: error: ld returned 1 exit status
$gcc main.c -llibmath
/usr/bin/ld: cannot find -llibmath
collect2: error: ld returned 1 exit status
$gcc -Wall main.c
main.c: In function ‘main’:
main.c:8:10: warning: ‘i’ is used uninitialized in this function [-Wuninitialized]
$gcc -Wall main.c -llibImath
main.c: In function ‘main’:
main.c:8:10: warning: ‘i’ is used uninitialized in this function [-Wuninitialized]
/usr/bin/ld: cannot find -llibImath
collect2: error: ld returned 1 exit status
$gcc -Wall main.c -lImath
main.c: In function ‘main’:
main.c:8:10: warning: ‘i’ is used uninitialized in this function [-Wuninitialized]
/usr/bin/ld: cannot find -lImath
collect2: error: ld returned 1 exit status
$gcc -Wall main.c -l Imath
main.c: In function ‘main’:
main.c:8:10: warning: ‘i’ is used uninitialized in this function [-Wuninitialized]
/usr/bin/ld: cannot find -lImath
collect2: error: ld returned 1 exit status
$gcc  main.c -lImath
/usr/bin/ld: cannot find -lImath
collect2: error: ld returned 1 exit status
$gcc  main.c -lImath
/usr/bin/ld: cannot find -lImath
collect2: error: ld returned 1 exit status
$ln -s /usr/lib/libImath.so.6
libImath.so.6      libImath.so.6.0.0
$ln -s /usr/lib/libImath.so.6.0.0 /usr/lib/libImath.so
ln: failed to create symbolic link `/usr/lib/libImath.so': Permission denied
$sudo ln -s /usr/lib/libImath.so.6.0.0 /usr/lib/libImath.so
$gcc  main.c -lImath
$

GCC commandline option -save-temps

-save-temps

Store the usual "temporary" intermediate files 
permanently; place them in the current directory
and name them based on the source file. Thus, 
compiling `foo.c' with `-c -save-temps' would produce
files `foo.i' and `foo.s', as well as `foo.o'. This
creates a preprocessed `foo.i' output file even though
the compiler now normally uses an integrated preprocessor. 


SESSION 1

$ls
main.c
$gcc -save-temp main.c
gcc: error: unrecognized command line option ‘-save-temp’
$gcc -save-temps main.c
$ls
a.out  main.c  main.i  main.o  main.s
$./a.out

 The Geek Stuff [0]
$ls -l main.o
-rw-r--r-- 1 jeffrin jeffrin 1504 Jan 25 21:18 main.o
$

SESSION 2


$cat hello.c 
#include 

main()
{
  printf("hello");
}
$gcc -save-temps hello.c 
hello.c:3:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
 main()
 ^~~~
$ls
a.out  hello.c  hello.i  hello.o  hello.s
$file he
hello.c  hello.i  hello.o  hello.s  
$file hello.i 
hello.i: C source, ASCII text
$file hello.o 
hello.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
$./hello.o
bash: ./hello.o: Permission denied
$chmod +x hello.o
$./hello.o
bash: ./hello.o: cannot execute binary file: Exec format error
$./hello.o
bash: ./hello.o: cannot execute binary file: Exec format error
$file hello.s
hello.s: assembler source, ASCII text
$head hello.s
	.file	"hello.c"
	.section	.rodata
.LC0:
	.string	"hello"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
$head hello.i
# 1 "hello.c"
# 1 ""
# 1 ""
# 31 ""
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "" 2
# 1 "hello.c"
# 1 "/usr/include/stdio.h" 1 3 4
# 27 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/features.h" 1 3 4
$