using vectors in C++ gives me an error that I cannot make any sense of -
the code follows:
#include <stdio.h> #include <math.h> #include <vector> float comp_cur(float a_x, float a_y, float b_x, float b_y, float c_x, float c_y); void comp_arr(std::vector<float> vals, std::vector<float> out, int scale, float dim); main(){ std::vector <float> curves; std::vector <float> inputs; inputs.push_back(2.0); inputs.push_back(3.0); inputs.push_back(6.0); inputs.push_back(1.0); inputs.push_back(7.0); comp_arr(inputs,curves,1.0,1.0); } float comp_cur(float a_x, float a_y, float b_x, float b_y, float c_x, float c_y){ b_x = b_x-a_x; b_y = b_y-a_y; c_x = c_x-a_x; c_y = c_y-a_y; a_x = 0; a_y = 0; float numerator_a = c_y*b_x - b_y*c_x; float denominator_a = c_x*c_x*b_x - c_x*b_x*b_x; float = numerator_a / denominator_a; float b = (b_y - a*b_x*b_x) / b_x; float curviture = 2*a / powf( (1 + (2*a*b_x + b)*(2*a*b_x + b)), 1.5); homecoming (curviture); } void comp_arr(std::vector<float> vals, std::vector<float> out, int scale, float dim){ for(int = scale; < sizeof(vals)-scale+1; i++){ float cur = comp_cur((i-scale)*dim, vals[i-1], i*dim, vals[i], (i+scale)*dim, vals[i+1]); out.push_back(cur); } }
everything comp_cur works fine, comp_arr function throwing hideous error. i'm pretty new c , c++ can't create sense of error @ all.
/tmp/cctcz2bx.o: in function `main': comp.cpp:(.text+0x174): undefined reference `__cxa_end_cleanup' /tmp/cctcz2bx.o:(.arm.extab+0x0): undefined reference `__gxx_personality_v0' /tmp/cctcz2bx.o: in function `std::vector<float, std::allocator<float> >::~vector()': comp.cpp:(.text._znst6vectorifsaifeed2ev[_znst6vectorifsaifeed5ev]+0x6c): undefined reference `__cxa_end_cleanup' /tmp/cctcz2bx.o:(.arm.extab.text._znst6vectorifsaifeed2ev[_znst6vectorifsaifeed5ev]+0x0): undefined reference `__gxx_personality_v0' /tmp/cctcz2bx.o: in function `std::vector<float, std::allocator<float> >::vector(std::vector<float, std::allocator<float> > const&)': comp.cpp:(.text._znst6vectorifsaifeec2erks1_[_znst6vectorifsaifeec5erks1_]+0xb4): undefined reference `__cxa_end_cleanup' /tmp/cctcz2bx.o:(.arm.extab.text._znst6vectorifsaifeec2erks1_[_znst6vectorifsaifeec5erks1_]+0x0): undefined reference `__gxx_personality_v0' /tmp/cctcz2bx.o: in function `std::_vector_base<float, std::allocator<float> >::~_vector_base()': comp.cpp:(.text._znst12_vector_baseifsaifeed2ev[_znst12_vector_baseifsaifeed5ev]+0x70): undefined reference `__cxa_end_cleanup' /tmp/cctcz2bx.o:(.arm.extab.text._znst12_vector_baseifsaifeed2ev[_znst12_vector_baseifsaifeed5ev]+0x0): undefined reference `__gxx_personality_v0' /tmp/cctcz2bx.o: in function `std::vector<float, std::allocator<float> >::_m_insert_aux(__gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator<float> > >, float const&)': comp.cpp:(.text._znst6vectorifsaifee13_m_insert_auxen9__gnu_cxx17__normal_iteratoripfs1_eerkf[std::vector<float, std::allocator<float> >::_m_insert_aux(__gnu_cxx::__normal_iterator< float*, std::vector<float, std::allocator<float> > >, float const&)]+0x290): undefined reference `__cxa_end_catch' comp.cpp:(.text._znst6vectorifsaifee13_m_insert_auxen9__gnu_cxx17__normal_iteratoripfs1_eerkf[std::vector<float, std::allocator<float> >::_m_insert_aux(__gnu_cxx::__normal_iterator< float*, std::vector<float, std::allocator<float> > >, float const&)]+0x294): undefined reference `__cxa_end_cleanup' comp.cpp:(.text._znst6vectorifsaifee13_m_insert_auxen9__gnu_cxx17__normal_iteratoripfs1_eerkf[std::vector<float, std::allocator<float> >::_m_insert_aux(__gnu_cxx::__normal_iterator< float*, std::vector<float, std::allocator<float> > >, float const&)]+0x2a0): undefined reference `__cxa_begin_catch' comp.cpp:(.text._znst6vectorifsaifee13_m_insert_auxen9__gnu_cxx17__normal_iteratoripfs1_eerkf[std::vector<float, std::allocator<float> >::_m_insert_aux(__gnu_cxx::__normal_iterator< float*, std::vector<float, std::allocator<float> > >, float const&)]+0x308): undefined reference `__cxa_rethrow' /tmp/cctcz2bx.o:(.arm.extab.text._znst6vectorifsaifee13_m_insert_auxen9__gnu_cxx17__normal_iteratoripfs1_eerkf[std::vector<float, std::allocator<float> >::_m_insert_aux(__gnu_cxx::__normal_iterator<float*, std::vector<float, std::allocator<float> > >, float const&)]+0x0): undefined reference `__gxx_personality_v0' /tmp/cctcz2bx.o: in function `std::_vector_base<float, std::allocator<float> >::_vector_base(unsigned int, std::allocator<float> const&)': comp.cpp:(.text._znst12_vector_baseifsaifeec2ejrks0_[_znst12_vector_baseifsaifeec5ejrks0_]+0x90): undefined reference `__cxa_end_cleanup' /tmp/cctcz2bx.o:(.arm.extab.text._znst12_vector_baseifsaifeec2ejrks0_[_znst12_vector_baseifsaifeec5ejrks0_]+0x0): undefined reference `__gxx_personality_v0' /tmp/cctcz2bx.o: in function `std::vector<float, std::allocator<float> >::_m_check_len(unsigned int, char const*) const': comp.cpp:(.text._znkst6vectorifsaifee12_m_check_lenejpkc[std::vector<float, std::allocator<float> >::_m_check_len(unsigned int, char const*) const]+0x54): undefined reference `std::__throw_length_error(char const*)' /tmp/cctcz2bx.o: in function `__gnu_cxx::new_allocator<float>::deallocate(float*, unsigned int)': comp.cpp:(.text._zn9__gnu_cxx13new_allocatorife10deallocateepfj[__gnu_cxx::new_allocator<float>::deallocate(float*, unsigned int)]+0x1c): undefined reference `operator delete(void*)' /tmp/cctcz2bx.o: in function `__gnu_cxx::new_allocator<float>::allocate(unsigned int, void const*)': comp.cpp:(.text._zn9__gnu_cxx13new_allocatorife8allocateejpkv[__gnu_cxx::new_allocator<float>::allocate(unsigned int, void const*)]+0x40): undefined reference `std::__throw_bad_alloc()' comp.cpp:(.text._zn9__gnu_cxx13new_allocatorife8allocateejpkv[__gnu_cxx::new_allocator<float>::allocate(unsigned int, void const*)]+0x50): undefined reference `operator new(unsigned int)' collect2: ld returned 1 exit status
i'll take educated guess without knowing how you're compiling.
make sure compile g++
rather gcc
- g++
automatically sets options compiling c++ you, including linking standard library. alternatively, give -lstdc++
, -x c++
options.
c++ vector compiler-errors
No comments:
Post a Comment