Linux下C++开发常用命令

本页面记录本人在Linux下进行C++开发时使用的常用命令,注意这里不包括比如ls,mv等linux命令,这里会持续更新。
首先假设你只有一个源程序文件,叫vec.cpp,编译后的可执行程序叫vec(本文最后附有该程序Demo)。

本人是在Centos6.4 64bit系统上进行测试的,GCC版本是4.4.7。

1. strings命令:查看系统glibc支持的版本

[root@lzv6 c++]# strings /usr/lib64/libstdc++.so.6 | grep GLIBC
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.4
GLIBC_2.3.2
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH
[root@lzv6 c++]# strings /lib64/libc.so.6 | grep GLIBC_
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_PRIVATE

2. g++ -E选项:预处理源文件

 [root@lzv6 c++]# g++ -E -o vec2.cpp vec.cpp
[root@lzv6 c++]# wc vec.cpp vec2.cpp
vec.cpp
vec2.cpp
总用量

上面每行分别代表行数、单次数、字节数。
 从这里也可以看出引入多余头文件是件多么可怕的事情,多引入一个头文件,就要预处理N行。你可以试着#include <stdio.h>,然后再看看增加了多少行。

3. ldd命令:显示目标文件的依赖库

     [root@lzv6 c++]# ldd vec
linux-vdso.so. => (0x00007fff8fbff000)
libstdc++.so. => /usr/lib64/libstdc++.so. (0x0000003317800000)
libm.so. => /lib64/libm.so. (0x000000309ca00000)
libgcc_s.so. => /lib64/libgcc_s.so. (0x0000003317400000)
libc.so. => /lib64/libc.so. (0x000000309ce00000)
/lib64/ld-linux-x86-.so. (0x000000309c600000) [root@lzv6 c++]# ldd -v vec // -v 表示 打印所有信息,例如包括符号的版本信息
linux-vdso.so. => (0x00007fff585ff000)
libstdc++.so. => /usr/lib64/libstdc++.so. (0x0000003317800000)
libm.so. => /lib64/libm.so. (0x000000309ca00000)
libgcc_s.so. => /lib64/libgcc_s.so. (0x0000003317400000)
libc.so. => /lib64/libc.so. (0x000000309ce00000)
/lib64/ld-linux-x86-.so. (0x000000309c600000) Version information:
./vec:
libgcc_s.so. (GCC_3.) => /lib64/libgcc_s.so.
libc.so. (GLIBC_2.2.5) => /lib64/libc.so.
libstdc++.so. (CXXABI_1.) => /usr/lib64/libstdc++.so.
libstdc++.so. (GLIBCXX_3.) => /usr/lib64/libstdc++.so.
/usr/lib64/libstdc++.so.:
libm.so. (GLIBC_2.2.5) => /lib64/libm.so.
ld-linux-x86-.so. (GLIBC_2.) => /lib64/ld-linux-x86-.so.
libgcc_s.so. (GCC_4.2.0) => /lib64/libgcc_s.so.
libgcc_s.so. (GCC_3.) => /lib64/libgcc_s.so.
libgcc_s.so. (GCC_3.) => /lib64/libgcc_s.so.
libc.so. (GLIBC_2.) => /lib64/libc.so.
libc.so. (GLIBC_2.) => /lib64/libc.so.
libc.so. (GLIBC_2.3.2) => /lib64/libc.so.
libc.so. (GLIBC_2.2.5) => /lib64/libc.so.
/lib64/libm.so.:
libc.so. (GLIBC_PRIVATE) => /lib64/libc.so.
libc.so. (GLIBC_2.2.5) => /lib64/libc.so.
/lib64/libgcc_s.so.:
libc.so. (GLIBC_2.) => /lib64/libc.so.
libc.so. (GLIBC_2.2.5) => /lib64/libc.so.
/lib64/libc.so.:
ld-linux-x86-.so. (GLIBC_PRIVATE) => /lib64/ld-linux-x86-.so.
ld-linux-x86-.so. (GLIBC_2.) => /lib64/ld-linux-x86-.so.

4. objdump命令:查看目标文件的动态引用符号表

 [root@lzv6 c++]# objdump -T vec

 vec:     file format elf64-x86-

 DYNAMIC SYMBOL TABLE:
DF *UND* GLIBCXX_3. _ZSt20__throw_length_errorPKc
DF *UND* GLIBCXX_3. _ZNSolsEi
w D *UND* __gmon_start__
w D *UND* _Jv_RegisterClasses
DF *UND* GLIBCXX_3. _ZdlPv
DF *UND* CXXABI_1. __cxa_rethrow
DF *UND* GLIBCXX_3. _ZNSt8ios_base4InitC1Ev
DF *UND* GLIBC_2.2.5 __libc_start_main
DF *UND* GLIBC_2.2.5 __cxa_atexit
DF *UND* GLIBCXX_3. _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
DF *UND* GLIBC_2.2.5 memmove
DF *UND* CXXABI_1. __cxa_end_catch
DF *UND* GLIBCXX_3. _ZSt17__throw_bad_allocv
DF *UND* CXXABI_1. __cxa_begin_catch
DF *UND* GLIBCXX_3. _Znwm
DF *UND* GCC_3. _Unwind_Resume
DF *UND* GLIBCXX_3. _ZNSt8ios_base4InitD1Ev
00000000006026e0 g DO .bss GLIBCXX_3. _ZSt4cout
DF *UND* CXXABI_1. __gxx_personality_v0

5. objdump命令:查看目标文件引用了GLIBC的哪些版本中的哪些函数

 [root@lzv6 c++]# objdump -T vec | grep GLIBC_
DF *UND* GLIBC_2.2.5 __libc_start_main
DF *UND* GLIBC_2.2.5 __cxa_atexit
DF *UND* GLIBC_2.2.5 memmove

6. nm命令:显示vec程序中使用的函数

 [root@lzv6 c++]# nm -o vec | grep print
vec:0000000000400c50 t _GLOBAL__I__Z9print_vecRKSt6vectorIiSaIiEE
vec:0000000000400b0c T _Z9print_inti
vec:0000000000400b42 T _Z9print_strPc
vec:0000000000400a84 T _Z9print_vecRKSt6vectorIiSaIiEE

7. c++filt命令:显示未重整(unmangled)的原函数声明

 [root@lzv6 c++]# nm  vec | grep 'print'
00000000004009e0 t _GLOBAL__I__Z9print_vecRKSt6vectorIiSaIiEE
0000000000400b00 T _Z9print_inti
0000000000400a90 T _Z9print_strPc
0000000000400a10 T _Z9print_vecRKSt6vectorIiSaIiEE
[root@lzv6 c++]# c++filt _Z9print_inti
print_int(int)
[root@lzv6 c++]# nm vec | grep print | c++filt
00000000004009e0 t global constructors keyed to _Z9print_vecRKSt6vectorIiSaIiEE
0000000000400b00 T print_int(int)
0000000000400a90 T print_str(char*)
0000000000400a10 T print_vec(std::vector<int, std::allocator<int> > const&)

8. nm命令:显示目标文件的所有符号清单

 [root@lzv6 c++]# nm -o vec
vec: d _DYNAMIC
vec: d _GLOBAL_OFFSET_TABLE_
vec:0000000000400c50 t _GLOBAL__I__Z9print_vecRKSt6vectorIiSaIiEE
vec:00000000004019b8 R _IO_stdin_used
vec: w _Jv_RegisterClasses
vec: U _Unwind_Resume@@GCC_3.
vec:0000000000400c10 t _Z41__static_initialization_and_destruction_0ii
vec:0000000000400b0c T _Z9print_inti
vec:0000000000400b42 T _Z9print_strPc
vec:0000000000400a84 T _Z9print_vecRKSt6vectorIiSaIiEE
vec: W _ZN9__gnu_cxx13new_allocatorIiE10deallocateEPim
vec:00000000004014b6 W _ZN9__gnu_cxx13new_allocatorIiE7destroyEPi
vec:00000000004015e8 W _ZN9__gnu_cxx13new_allocatorIiE8allocateEmPKv
vec:0000000000400eae W _ZN9__gnu_cxx13new_allocatorIiE9constructEPiRKi
vec: W _ZN9__gnu_cxx13new_allocatorIiEC1Ev
vec: W _ZN9__gnu_cxx13new_allocatorIiEC2Ev
vec:00000000004014fa W _ZN9__gnu_cxx13new_allocatorIiED1Ev
vec:00000000004014fa W _ZN9__gnu_cxx13new_allocatorIiED2Ev
vec:00000000004014c4 W _ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEC1ERKS1_
vec:00000000004014c4 W _ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEC2ERKS1_
vec:00000000004013fb W _ZN9__gnu_cxxmiIPiSt6vectorIiSaIiEEEENS_17__normal_iteratorIT_T0_E15difference_typeERKS8_SB_
vec:00000000004016bc W _ZNK9__gnu_cxx13new_allocatorIiE8max_sizeEv
vec:00000000004012a6 W _ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEE4baseEv
vec:00000000004012fa W _ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv
vec:00000000004016ae W _ZNKSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv
vec:000000000040130c W _ZNKSt6vectorIiSaIiEE12_M_check_lenEmPKc
vec:0000000000400c78 W _ZNKSt6vectorIiSaIiEE4sizeEv
vec:000000000040159a W _ZNKSt6vectorIiSaIiEE8max_sizeEv
vec:0000000000400ca2 W _ZNKSt6vectorIiSaIiEEixEm
vec:00000000004014e0 W _ZNSaIiEC1Ev
vec:00000000004014e0 W _ZNSaIiEC2Ev
vec: W _ZNSaIiED1Ev
vec: W _ZNSaIiED2Ev
vec: U _ZNSolsEi@@GLIBCXX_3.
vec: W _ZNSt11__copy_moveILb0ELb1ESt26random_access_iterator_tagE8__copy_mIiEEPT_PKS3_S6_S4_
vec: W _ZNSt12_Destroy_auxILb1EE9__destroyIPiEEvT_S3_
vec: W _ZNSt12_Vector_baseIiSaIiEE11_M_allocateEm
vec:00000000004011f4 W _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev
vec:00000000004011f4 W _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev
vec:0000000000400dc4 W _ZNSt12_Vector_baseIiSaIiEE12_Vector_implD1Ev
vec:0000000000400dc4 W _ZNSt12_Vector_baseIiSaIiEE12_Vector_implD2Ev
vec:000000000040124c W _ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim
vec:0000000000400e76 W _ZNSt12_Vector_baseIiSaIiEE19_M_get_Tp_allocatorEv
vec:0000000000400dde W _ZNSt12_Vector_baseIiSaIiEEC1Ev
vec:0000000000400dde W _ZNSt12_Vector_baseIiSaIiEEC2Ev
vec:0000000000400df8 W _ZNSt12_Vector_baseIiSaIiEED1Ev
vec:0000000000400df8 W _ZNSt12_Vector_baseIiSaIiEED2Ev
vec: W _ZNSt12__miter_baseIPiLb0EE3__bES0_
vec:000000000040166e W _ZNSt12__niter_baseIPiLb0EE3__bES0_
vec:00000000004016fd W _ZNSt20__copy_move_backwardILb0ELb1ESt26random_access_iterator_tagE13__copy_move_bIiEEPT_PKS3_S6_S4_
vec: W _ZNSt20__uninitialized_copyILb1EE18uninitialized_copyIPiS2_EET0_T_S4_S3_
vec:0000000000400ee6 W _ZNSt6vectorIiSaIiEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPiS1_EERKi
vec:00000000004011ca W _ZNSt6vectorIiSaIiEE3endEv
vec:00000000004013d6 W _ZNSt6vectorIiSaIiEE5beginEv
vec:0000000000400d4a W _ZNSt6vectorIiSaIiEE9push_backERKi
vec:0000000000400cc2 W _ZNSt6vectorIiSaIiEEC1Ev
vec:0000000000400cc2 W _ZNSt6vectorIiSaIiEEC2Ev
vec:0000000000400cdc W _ZNSt6vectorIiSaIiEED1Ev
vec:0000000000400cdc W _ZNSt6vectorIiSaIiEED2Ev
vec: U _ZNSt8ios_base4InitC1Ev@@GLIBCXX_3.
vec: U _ZNSt8ios_base4InitD1Ev@@GLIBCXX_3.
vec: W _ZSt13__copy_move_aILb0EPiS0_ET1_T0_S2_S1_
vec:00000000004012b4 W _ZSt13copy_backwardIPiS0_ET0_T_S2_S1_
vec:00000000004017d8 W _ZSt14__copy_move_a2ILb0EPiS0_ET1_T0_S2_S1_
vec: U _ZSt17__throw_bad_allocv@@GLIBCXX_3.
vec:00000000004016d0 W _ZSt18uninitialized_copyIPiS0_ET0_T_S2_S1_
vec: U _ZSt20__throw_length_errorPKc@@GLIBCXX_3.
vec:000000000040167c W _ZSt22__copy_move_backward_aILb0EPiS0_ET1_T0_S2_S1_
vec: W _ZSt22__uninitialized_copy_aIPiS0_iET0_T_S2_S1_RSaIT1_E
vec:000000000040147a W _ZSt22__uninitialized_move_aIPiS0_SaIiEET0_T_S3_S2_RT1_
vec: W _ZSt23__copy_move_backward_a2ILb0EPiS0_ET1_T0_S2_S1_
vec:00000000004015bc W _ZSt3maxImERKT_S2_S2_
vec: W _ZSt4copyIPiS0_ET0_T_S2_S1_
vec:00000000006026e0 B _ZSt4cout@@GLIBCXX_3.
vec: W _ZSt8_DestroyIPiEvT_S1_
vec:0000000000400e84 W _ZSt8_DestroyIPiiEvT_S1_RSaIT0_E
vec: b _ZStL8__ioinit
vec: U _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@@GLIBCXX_3.
vec: U _ZdlPv@@GLIBCXX_3.
vec: U _Znwm@@GLIBCXX_3.
vec:0000000000400c65 W _ZnwmPv
vec: d __CTOR_END__
vec: d __CTOR_LIST__
vec: D __DTOR_END__
vec: d __DTOR_LIST__
vec:00000000004023d0 r __FRAME_END__
vec: d __JCR_END__
vec: d __JCR_LIST__
vec:00000000006026c4 A __bss_start
vec: U __cxa_atexit@@GLIBC_2.2.5
vec: U __cxa_begin_catch@@CXXABI_1.
vec: U __cxa_end_catch@@CXXABI_1.
vec: U __cxa_rethrow@@CXXABI_1.
vec:00000000006026c0 D __data_start
vec: t __do_global_ctors_aux
vec:00000000004009f0 t __do_global_dtors_aux
vec:00000000004019c0 R __dso_handle
vec: w __gmon_start__
vec: U __gxx_personality_v0@@CXXABI_1.
vec:000000000060242c d __init_array_end
vec:000000000060242c d __init_array_start
vec:00000000004018d0 T __libc_csu_fini
vec:00000000004018e0 T __libc_csu_init
vec: U __libc_start_main@@GLIBC_2.2.5
vec:00000000006026c4 A _edata
vec: A _end
vec:00000000004019a8 T _fini
vec: T _init
vec:00000000004009a0 T _start
vec:00000000004009cc t call_gmon_start
vec:00000000006027f0 b completed.
vec:00000000006026c0 W data_start
vec:00000000006027f8 b dtor_idx.
vec:0000000000400a60 t frame_dummy
vec:0000000000400b7b T main
vec: U memmove@@GLIBC_2.2.5

9. strace命令:显示在预处理的时候读取的所有头文件

 [root@lzv6 c++]# strace -f -e open cpp vec.cpp -o /dev/null >& | grep -v ENOENT | awk '{print $3}'
=
=
=
=
=
=
attached
open("/etc/ld.so.cache",
open("/usr/lib64/libmpfr.so.1",
open("/usr/lib64/libgmp.so.3",
open("/lib64/libdl.so.2",
open("/lib64/libc.so.6",
open("/usr/lib/locale/locale-archive",
open("/usr/share/locale/locale.alias",
open("/usr/share/locale/zh_CN/LC_MESSAGES/gcc.mo",
open("/usr/lib64/gconv/gconv-modules.cache",
open("/proc/meminfo",
open("/proc/meminfo",
open("/proc/meminfo",
open("/dev/null",
open("vec.cpp",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iostream",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/x86_64-redhat-linux/bits/c++config.h",
open("/usr/include/bits/wordsize.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/x86_64-redhat-linux/bits/os_defines.h",
open("/usr/include/features.h",
open("/usr/include/sys/cdefs.h",
open("/usr/include/bits/wordsize.h",
open("/usr/include/gnu/stubs.h",
open("/usr/include/bits/wordsize.h",
open("/usr/include/gnu/stubs-64.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/x86_64-redhat-linux/bits/cpu_defines.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ios",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iosfwd",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stringfwd.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/postypes.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cstddef",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/stddef.h",
open("/usr/include/wchar.h",
open("/usr/include/stdio.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/stdarg.h",
open("/usr/include/bits/wchar.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/stddef.h",
open("/usr/include/xlocale.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/char_traits.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_algobase.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cstddef",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/stddef.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/functexcept.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception_defines.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/cpp_type_traits.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/type_traits.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/numeric_traits.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_pair.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/move.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cstddef",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/stddef.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/concept_check.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_iterator_base_types.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cstddef",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/stddef.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_iterator_base_funcs.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_iterator.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/debug/debug.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cstddef",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/stddef.h",
open("/usr/include/wchar.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/localefwd.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/x86_64-redhat-linux/bits/c++locale.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/clocale",
open("/usr/include/locale.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/stddef.h",
open("/usr/include/bits/locale.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cstddef",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/stddef.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cctype",
open("/usr/include/ctype.h",
open("/usr/include/bits/types.h",
open("/usr/include/bits/wordsize.h",
open("/usr/include/bits/typesizes.h",
open("/usr/include/endian.h",
open("/usr/include/bits/endian.h",
open("/usr/include/bits/byteswap.h",
open("/usr/include/bits/wordsize.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/ios_base.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/atomicity.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/x86_64-redhat-linux/bits/gthr.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/x86_64-redhat-linux/bits/gthr-default.h",
open("/usr/include/pthread.h",
open("/usr/include/sched.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/stddef.h",
open("/usr/include/time.h",
open("/usr/include/bits/sched.h",
open("/usr/include/time.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/stddef.h",
open("/usr/include/bits/time.h",
open("/usr/include/bits/pthreadtypes.h",
open("/usr/include/bits/wordsize.h",
open("/usr/include/bits/setjmp.h",
open("/usr/include/bits/wordsize.h",
open("/usr/include/bits/wordsize.h",
open("/usr/include/unistd.h",
open("/usr/include/bits/posix_opt.h",
open("/usr/include/bits/environments.h",
open("/usr/include/bits/wordsize.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/stddef.h",
open("/usr/include/bits/confname.h",
open("/usr/include/getopt.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/x86_64-redhat-linux/bits/atomic_word.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/locale_classes.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/string",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/allocator.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/x86_64-redhat-linux/bits/c++allocator.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ext/new_allocator.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/new",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cstddef",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/include/stddef.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/ostream_insert.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cxxabi-forced.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_function.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/backward/binders.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/basic_string.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/initializer_list",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/basic_string.tcc",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/locale_classes.tcc",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/streambuf",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/streambuf.tcc",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/basic_ios.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/locale_facets.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwctype",
open("/usr/include/wctype.h",
open("/usr/include/wchar.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cctype",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/x86_64-redhat-linux/bits/ctype_base.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/streambuf_iterator.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/x86_64-redhat-linux/bits/ctype_inline.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/locale_facets.tcc",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/basic_ios.tcc",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/ostream.tcc",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/istream",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/istream.tcc",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/vector",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_construct.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_uninitialized.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_vector.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_bvector.h",
open("/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/vector.tcc",
detached
(Child

我的测试代码:

 #include <iostream>
#include <vector> void print_vec(const std::vector<int>& vec)
{
std::cout << "print vec : ";
size_t size = vec.size();
for(size_t i = ; i<size; i++)
std::cout << vec[i] << "\t";
std::cout << "\n";
} void print_int(int i)
{
std::cout<<"print_int : " << i << "\n";
} void print_str(char* str)
{
std::cout<<"print_str : " << str << "\n";
} int main()
{
std::vector<int> vec;
vec.push_back(); print_vec(vec);
print_int(vec.size());
print_str("hello world!"); return ;
} //编译:
//g++ -o vec vec.cpp
上一篇:地图、定位 CLLocationManager CLGeocoder CLPlacemark


下一篇:手把手教你写Kconfig---基于tiny4412开发板