- 论坛徽章:
- 0
|
首先声明,我是新手,楼主的两个程序在我的电脑上都有错误
第一个,编译失败
- [yms@hk-vas idea1]$ gcc c_test.cpp
- /tmp/ccLWexkY.o(.text+0x96): In function `main':
- : undefined reference to `log'
- /tmp/ccLWexkY.o(.text+0xab): In function `main':
- : undefined reference to `log'
- /tmp/ccLWexkY.o(.text+0xfa): In function `main':
- : undefined reference to `log'
- /tmp/ccLWexkY.o(.text+0x10f): In function `main':
- : undefined reference to `log'
- /tmp/ccLWexkY.o(.text+0x17f): In function `main':
- : undefined reference to `log'
- /tmp/ccLWexkY.o(.text+0x197): more undefined references to `log' follow
- /tmp/ccLWexkY.o(.text+0x28f): In function `main':
- : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char,
- std::char_traits<char> >&)'
- /tmp/ccLWexkY.o(.text+0x2aa): In function `main':
- : undefined reference to `std::cout'
- /tmp/ccLWexkY.o(.text+0x2af): In function `main':
- : undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)'
- /tmp/ccLWexkY.o(.text+0x2b8): In function `main':
- : undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
- /tmp/ccLWexkY.o(.text+0x31c): In function `__static_initialization_and_destruction_0(int, int)':
- : undefined reference to `std::ios_base::Init::Init[in-charge]()'
- /tmp/ccLWexkY.o(.text+0x34b): In function `__tcf_0':
- : undefined reference to `std::ios_base::Init::~Init [in-charge]()'
- /tmp/ccLWexkY.o(.gnu.linkonce.t._ZNSt6vectorIiSaIiEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPiS1_EERKi+0x1a0): In function `std::vector<int, std::allocator<int> >::_M_insert_aux(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, int const&)':
- : undefined reference to `__cxa_begin_catch'
- /tmp/ccLWexkY.o(.gnu.linkonce.t._ZNSt6vectorIiSaIiEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPiS1_EERKi+0x1dd): In function `std::vector<int, std::allocator<int> >::_M_insert_aux(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, int const&)':
- : undefined reference to `__cxa_rethrow'
- /tmp/ccLWexkY.o(.gnu.linkonce.t._ZNSt6vectorIiSaIiEE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPiS1_EERKi+0x1e8): In function `std::vector<int, std::allocator<int> >::_M_insert_aux(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, int const&)':
- : undefined reference to `__cxa_end_catch'
- /tmp/ccLWexkY.o(.gnu.linkonce.t._ZNSt14__simple_allocIiSt24__default_alloc_templateILb1ELi0EEE10deallocateEPij+0x1a): In function `std::__simple_alloc<int, std::__default_alloc_template<(bool)1, (int)0> >::deallocate(int*, unsigned)':
- : undefined reference to `std::__default_alloc_template<(bool)1, (int)0>::deallocate(void*, unsigned)'
- /tmp/ccLWexkY.o(.gnu.linkonce.t._ZNSt14__simple_allocIiSt24__default_alloc_templateILb1ELi0EEE8allocateEj+0x1e): In function `std::__simple_alloc<int, std::__default_alloc_template<(bool)1, (int)0> >::allocate(unsigned)':
- : undefined reference to `std::__default_alloc_template<(bool)1, (int)0>::allocate(unsigned)'
- /tmp/ccLWexkY.o(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
- collect2: ld returned 1 exit status
复制代码
第二个,运行时出错:
- [yms@hk-vas idea2]$ time ./a.out
- 1
- 段错误
-
- real 0m0.081s
- user 0m0.000s
- sys 0m0.000s
复制代码 |
|