����������� � �������� -o ��������������������������� �������� > g++ -o hello hello.C > ./hello CS2141 – Software Development using C/C++ Hello world! ������������ � !���������������� � -g ��������� ��������������������������������� �� ����������� � -Wall ������������������������������!�������������� ����������� �������������������������������������� �������"������������������������������� ���������� > g++ -g -Wall -o hello hello.C Compiling a C++ Program 3 ������������������������ ��� � #���������������������������������"������������������� �� � ���������������������������� ������������������������������������������� � ����������������������������������� > g++ -o quack quack.C moo.C #include <iostream> � ��������������������$��������������%����������������� using namespace std; ����������������������� int main( ) { cout << “Hello world!” << endl; � �������� -c ������������������� ����������� � } � ������ � g++ hello.C ����������������������������� > g++ -c quack.C ������� ���������� a.out � > g++ -c moo.C � ��������������������������� quack.o ����� moo.o � � �������� ./a.out ����������������������� Compiling a C++ Program 4 Compiling a C++ Program 2
����������������������������� ������������������������������ � ���������������� ����������������������� � ����� %����������������������&����������� ����������� ��� ������������������ � cpp hello.C > hello.ii > g++ -o quack quack.o moo.o +���������������������������������, � �������������������������������"�������������������� ����������������� � g++ -s hello.C ��������� ������������� ����������������� � g++ -c hello.C > g++ -c quack.C .file "hello.C 01011101010101011 # 1 "hello.C" #include <iostream> .local _ZSt8__i 10101011010101100 using namespace std # 1 "<built-in>" > g++ -o quack quack.o moo.o .comm _ZSt8__i 10100001001111001 # 1 "<command line .text 00001011110110101 int main( ) # 1 "hello.C" .align 2 01011100001010100 # 1 "/usr/include/ { .globl main 00001110101100111 int i, n; # 42 "/usr/include .type main, @f 01010101100101010 � ���� %���������������������������������������� main: 01010101101000011 cin >> n; # 43 "/usr/include .LFB1512: *����������� 00010010101010100 # 4294967220 "/usr �������� for( i = 0; i < pushl %ebp 11001011011011010 ����� ��� cout << “Hell .LCFI0: 10101010101001011 )��&�� # 44 "/usr/include cout << “From “ movl %esp, %e 10111100010101111 return 0; # 1 "/usr/include/ .LCFI1: 11100000001010100 # 35 "/usr/include �����&��������������� %��������������������� } subl $24, %es hello.o hello.s a.out hello.ii hello.C ������� ����������� Compiling a C++ Program 7 Compiling a C++ Program 5 ����������������������������� ����������������������� � *����������������������$������������������������� � '�������������������������� g++ hello.C �� � ������������ �+���������,������������������&�������� � (����� hello.C ������������������ ������������������������������������ � ������������������������������������������ �������� � ������������ �+���������,���������������������������� � ��������� ���������������� �������������������� ���������������������������� � �����������������������&������������������������� ��� � -����������������������������������������������������� .file "hello.C 01011101010101011 # 1 "hello.C" #include <iostream> .local _ZSt8__i 10101011010101100 using namespace std # 1 "<built-in>" .comm _ZSt8__i 10100001001111001 # 1 "<command line .text 00001011110110101 int main( ) # 1 "hello.C" ����������������������� #include ��������$�� .align 2 01011100001010100 # 1 "/usr/include/ { .globl main 00001110101100111 int i, n; # 42 "/usr/include .type main, @f 01010101100101010 main: 01010101101000011 cin >> n; # 43 "/usr/include .LFB1512: *����������� 00010010101010100 # 4294967220 "/usr �������� for( i = 0; i < pushl %ebp 11001011011011010 ����� ��� cout << “Hell .LCFI0: 10101010101001011 )��&�� # 44 "/usr/include cout << “From “ movl %esp, %e 10111100010101111 �� return 0; # 1 "/usr/include/ .LCFI1: 11100000001010100 # 35 "/usr/include } subl $24, %es #include <file.h> hello.o hello.s a.out hello.ii hello.C #include “file.h” Compiling a C++ Program 8 Compiling a C++ Program 6
Recommend
More recommend