GCC + std:vector macht Probleme !



  • Hallo,

    ich habe folgenden test gemacht und dem gcc-Compiler schmeckt das nicht.
    Warum oder kennt jemand solches Problem ?

    #include <vector>

    ....

    std::vector<int> vec ;
    vec.resize(10) ;

    ..

    Und hier die Fehlermeldung :

    /tmp/ccYzUAno.o: In function \_\_malloc\_alloc\_template<0>::\_S\_oom\_malloc(unsigned int)': /tmp/ccYzUAno.o(.\_\_malloc\_alloc\_template<0>::gnu.linkonce.t.\_S\_oom\_malloc(unsigned int)+0x1a): undefined reference toe
    ndl(ostream &)'
    /tmp/ccYzUAno.o(.__malloc_alloc_template<0>::gnu.linkonce.t._S_oom_malloc(unsigned int)+0x27): undefined reference to c err' /tmp/ccYzUAno.o(.\_\_malloc\_alloc\_template<0>::gnu.linkonce.t.\_S\_oom\_malloc(unsigned int)+0x2c): undefined reference too
    stream::operator<<(char const )'
    /tmp/ccYzUAno.o(.__malloc_alloc_template<0>::gnu.linkonce.t._S_oom_malloc(unsigned int)+0x37): undefined reference to `o
    stream::operator<<(ostream &(
    )(ostream &))'
    collect2: ld returned 1 exit status



  • zeig mal die commandline, mit der du gcc/g++ aufrufst...



  • ganz einfach
    gcc test.C

    und in "test.C" steht

    #include <stdio.h>
    #include <stdlib.h>
    #include <vector>
    main()
    {
    float x = 0.3 ;
    std::vector<int> arr ; // diese Zeile macht keine Probleme !
    ar.resize(10) ; // diese Zeile macht Probleme
    std::vector<int> vec(10) ; // diese Zeile macht auch Probleme !

    printf(" x = %g \n", x) ;
    scanf("hallo !", &x) ;
    }



  • witzig!! std::vector ist ne C++ Sache. Die kannst du nicht als C kompilieren.



  • OK ! Habe eingesehen gcc durch g++ zu ersetzen und es funzt.

    Danke !


Anmelden zum Antworten