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
$

lspci -vmm . Dump PCI device data in a machine readable form for easy parsing by scripts

commandline session

$lspci -vmm
Slot:	00:00.0
Class:	RAM memory
Vendor:	NVIDIA Corporation
Device:	MCP61 Memory Controller
SVendor:	Giga-byte Technology
SDevice:	Device 5001
Rev:	a1

Slot:	00:01.0
Class:	ISA bridge
Vendor:	NVIDIA Corporation
Device:	MCP61 LPC Bridge
SVendor:	Giga-byte Technology
SDevice:	Device 0c11
Rev:	a2

Slot:	00:01.1
Class:	SMBus
Vendor:	NVIDIA Corporation
Device:	MCP61 SMBus
SVendor:	Giga-byte Technology
SDevice:	Device 0c11
Rev:	a2

Slot:	00:01.2
Class:	RAM memory
Vendor:	NVIDIA Corporation
Device:	MCP61 Memory Controller
SVendor:	Giga-byte Technology
SDevice:	Device 0c11
Rev:	a2

Slot:	00:02.0
Class:	USB controller
Vendor:	NVIDIA Corporation
Device:	MCP61 USB 1.1 Controller
SVendor:	Giga-byte Technology
SDevice:	Device 5004
Rev:	a2
ProgIf:	10

Slot:	00:02.1
Class:	USB controller
Vendor:	NVIDIA Corporation
Device:	MCP61 USB 2.0 Controller
SVendor:	Giga-byte Technology
SDevice:	Device 5004
Rev:	a2
ProgIf:	20

Slot:	00:04.0
Class:	PCI bridge
Vendor:	NVIDIA Corporation
Device:	MCP61 PCI bridge
Rev:	a1
ProgIf:	01

Slot:	00:05.0
Class:	Audio device
Vendor:	NVIDIA Corporation
Device:	MCP61 High Definition Audio
SVendor:	Giga-byte Technology
SDevice:	Device a002
Rev:	a2

Slot:	00:06.0
Class:	IDE interface
Vendor:	NVIDIA Corporation
Device:	MCP61 IDE
SVendor:	Giga-byte Technology
SDevice:	Device 5002
Rev:	a2
ProgIf:	8a

Slot:	00:07.0
Class:	Bridge
Vendor:	NVIDIA Corporation
Device:	MCP61 Ethernet
SVendor:	Giga-byte Technology
SDevice:	Device e000
Rev:	a2

Slot:	00:08.0
Class:	IDE interface
Vendor:	NVIDIA Corporation
Device:	MCP61 SATA Controller
SVendor:	Giga-byte Technology
SDevice:	Device b002
Rev:	a2
ProgIf:	85

Slot:	00:0d.0
Class:	VGA compatible controller
Vendor:	NVIDIA Corporation
Device:	C61 [GeForce 6150SE nForce 430]
SVendor:	Giga-byte Technology
SDevice:	Device d000
Rev:	a2

Slot:	00:18.0
Class:	Host bridge
Vendor:	Advanced Micro Devices [AMD]
Device:	K8 [Athlon64/Opteron] HyperTransport Technology Configuration

Slot:	00:18.1
Class:	Host bridge
Vendor:	Advanced Micro Devices [AMD]
Device:	K8 [Athlon64/Opteron] Address Map

Slot:	00:18.2
Class:	Host bridge
Vendor:	Advanced Micro Devices [AMD]
Device:	K8 [Athlon64/Opteron] DRAM Controller

Slot:	00:18.3
Class:	Host bridge
Vendor:	Advanced Micro Devices [AMD]
Device:	K8 [Athlon64/Opteron] Miscellaneous Control

Slot:	01:06.0
Class:	Ethernet controller
Vendor:	Belkin
Device:	F5D7000 v7000 Wireless G Desktop Card [Realtek RTL8185]
SVendor:	Belkin
SDevice:	F5D7000 v7000 Wireless G Desktop Card [Realtek RTL8185]
Rev:	20

$

GCC COMMANDLINE OPTIONS PART 2

commandline session

$gcc -S main.c > main.s
$cat main.s
.file "main.c"
.section .rodata
.LC0:
.string "n The Geek Stuff [%d]n"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movl -4(%rbp), %eax
movl %eax, %esi
movl $.LC0, %edi
movl $0, %eax
call printf
movl $0, %eax
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Debian 4.7.2-4) 4.7.2"
.section .note.GNU-stack,"",@progbits
$

GCC COMMANDLINE OPTIONS PART 1

commandline session

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

int main(void)
{
printf("n The Geek Stuffn");
return 0;
}
$gcc main.c
$./a.out

The Geek Stuff
$gcc main.c -o main
$./main

The Geek Stuff
$gcc -Wall main.c -o main
$./main

The Geek Stuff
$cat main.c
#include<stdio.h>

int main(void)
{
int i;
printf("n The Geek Stuff [%d]n", i);
return 0;
}
$gcc -Wall main.c -o main
main.c: In function ‘main’:
main.c:6:10: warning: ‘i’ is used uninitialized in this function [-Wuninitialized]
$gcc -E main.c > main.i

FREE COMMAND WITH DIFFERENT UNITS

commandline session

$free -b
             total       used       free     shared    buffers     cached
Mem:    2043490304 1840762880  202727424          0   37040128  823631872
-/+ buffers/cache:  980090880 1063399424
Swap:   5984219136   15114240 5969104896
$free -k
             total       used       free     shared    buffers     cached
Mem:       1995596    1795388     200208          0      36196     804388
-/+ buffers/cache:     954804    1040792
Swap:      5843964      14760    5829204
$free -m
             total       used       free     shared    buffers     cached
Mem:          1948       1749        199          0         35        785
-/+ buffers/cache:        928       1020
Swap:         5706         14       5692
$free -g
             total       used       free     shared    buffers     cached
Mem:             1          1          0          0          0          0
-/+ buffers/cache:          0          0
Swap:            5          0          5
$

DEBIAN xrandr The X Resize, Rotate and Reflect Extension (RandR)

$xrandr | grep connected
VGA-0 connected 1024x768+0+0 (normal left inverted right x axis y axis) 340mm x 270mm
$xrandr --output VGA-0 --brightness 1
$xrandr --output VGA-0 --brightness 0.5
$

Theory Drop
The X Resize, Rotate and Reflect Extension (RandR)[2] is an X Window System extension, which allows clients to dynamically change X screens, so as to resize, rotate and reflect the root window of a screen.

source:http://en.wikipedia.org/wiki/RandR

UNIT TESTING trueprint

commandline session

$ls
acconfig.h  bootstrap  config.cache  config.log     configure.in  INSTALL      Makefile.in  replace  stamp-h1.in
aclocal.m4  ChangeLog  config.h      config.status  COPYING	  Makefile     NEWS	    src      stamp-h2.in
AUTHORS     config     config.h.in   configure	    doc		  Makefile.am  README	    stamp-h  tests
$make check
Makefile:122: warning: overriding commands for target `config.h'
Makefile:103: warning: ignoring old commands for target `config.h'
Makefile:132: warning: overriding commands for target `config.h.in'
Makefile:113: warning: ignoring old commands for target `config.h.in'
Making check in replace
make[1]: Entering directory `/home/jeffrin/unit.test/trueprint-5.3/replace'
rm -f libreplace.a
ar cru libreplace.a
ranlib libreplace.a
make[1]: Leaving directory `/home/jeffrin/unit.test/trueprint-5.3/replace'
Making check in src
make[1]: Entering directory `/home/jeffrin/unit.test/trueprint-5.3/src'
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c debug.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c index.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c lang_verilog.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c lang_perl.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c postscript.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c diffs.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c input.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c language.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c lang_pike.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c print_prompt.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c expand_str.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c lang_c.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c main.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c lang_report.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c printers_fl.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c getopt.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c lang_cxx.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c openpipe.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c lang_sh.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c getopt1.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c lang_java.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c options.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c utils.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c headers.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c lang_text.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c lang_pascal.c
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I.. -I.. -I..   -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2 -c output.c
gcc -DPRINTERS_FILE="/usr/local/lib/printers" -g -O2  -o trueprint  debug.o index.o lang_verilog.o lang_perl.o postscript.o diffs.o input.o language.o lang_pike.o print_prompt.o expand_str.o lang_c.o main.o lang_report.o printers_fl.o getopt.o lang_cxx.o openpipe.o lang_sh.o getopt1.o lang_java.o options.o utils.o headers.o lang_text.o lang_pascal.o output.o
make[1]: Leaving directory `/home/jeffrin/unit.test/trueprint-5.3/src'
Making check in doc
make[1]: Entering directory `/home/jeffrin/unit.test/trueprint-5.3/doc'
make[1]: Nothing to be done for `check'.
make[1]: Leaving directory `/home/jeffrin/unit.test/trueprint-5.3/doc'
Making check in tests
make[1]: Entering directory `/home/jeffrin/unit.test/trueprint-5.3/tests'
make  check-TESTS
make[2]: Entering directory `/home/jeffrin/unit.test/trueprint-5.3/tests'
top_builddir = ..
srcdir = .
1 Single C source file... passed
2 Two C source files... passed
3 Text file followed by C source file... passed
4 Diff of two files... passed
5 Diff of two files with long options... passed
6 Another diff of two files... passed
7 Another diff of two files with long options... passed
8 Diffs using a prefix... passed
9 Diffs using a prefix with long options... passed
10 Very long source line... passed
11 Set interline gap & pointsize & page length -g -p -l... passed
12 Set interline gap & pointsize & page length with long options... passed
13 Change date & time in headers -X... passed
14 Change date & time in headers with long options... passed
15 Use login name in headers -X %l... passed
16 Use login name in headers --left-header=%l... passed
17 Print message over page -m... passed
18 Print message over page --message... passed
19 Use current filename for message string -m %n... passed
20 Use current filename for message string --message %n... passed
21 Use landscape mode -ol... passed
22 Use landscape mode with long option... passed
23 Print 2-on-1 -2... passed
24 Print 2-on-1 --two-up... passed
25 Print 4-on-1 -4... passed
26 Print 4-on-1 --four-up... passed
27 Long lines & page width -w... passed
28 Long lines & page width --line-wrap... passed
29 Turn off intelligent linewrap -Wn... passed
30 Turn off intelligent linewrap with long options... passed
31 Exclude braces depth count for C, line number count -in -nn... passed
32 Exclude braces depth count for C, line number count with long options... passed
33 Print double-sided -S2... passed
34 Print double-sided --double-sided... passed
35 Suppress everything -C -F -f -B... passed
36 Suppress everything using long options... passed
37 Set tabsize wierdly -T5... passed
38 Set tabsize wierdly using long option... passed
39 Set headers/footers... passed
40 Set headers/footers using long options... passed
41 Indent for holepunch --I... passed
42 Indent for holepunch using long options... passed
43 Suppress headers --K... passed
44 Suppress headers using long options... passed
45 Suppress footers --k... passed
46 Suppress footers using long options... passed
47 Stdin for default... passed
48 - for stdin... passed
49 No new sheet for new filepassed
49 out of 49 tests passed
To complete the test, print a file using trueprint
PASS: Run
==================
All 1 tests passed
==================
make[2]: Leaving directory `/home/jeffrin/unit.test/trueprint-5.3/tests'
make[1]: Leaving directory `/home/jeffrin/unit.test/trueprint-5.3/tests'
make[1]: Entering directory `/home/jeffrin/unit.test/trueprint-5.3'
Makefile:122: warning: overriding commands for target `config.h'
Makefile:103: warning: ignoring old commands for target `config.h'
Makefile:132: warning: overriding commands for target `config.h.in'
Makefile:113: warning: ignoring old commands for target `config.h.in'
cd . 
	  && CONFIG_FILES= CONFIG_HEADERS=config.h 
	     /bin/sh ./config.status
creating config.h
config.h is unchanged
cd . 
	  && CONFIG_FILES= CONFIG_HEADERS=config.h 
	     /bin/sh ./config.status
creating config.h
config.h is unchanged
make[1]: Leaving directory `/home/jeffrin/unit.test/trueprint-5.3'
$