Kompilieren mit gcc schlägt fehl



  • Diese ellenlangen Fehlermeldungen bringen uns nichts, sorry.

    Wenn das nicht kompiliert, dann ist Deine g++-Installation kaputt.

    // hello.cpp
    // kompilieren mit "g++ -o hello hello.cpp"
    #include <iostream>
    
    int main()
    {
        std::cout << "Hello world";
    }
    


  • nman schrieb:

    Diese ellenlangen Fehlermeldungen bringen uns nichts, sorry.

    Wenn das nicht kompiliert, dann ist Deine g++-Installation kaputt.

    // hello.cpp
    // kompilieren mit "g++ -o hello hello.cpp"
    #include <iostream>
    
    int main()
    {
        std::cout << "Hello world";
    }
    

    genau so gemacht nun bekomme ich:

    zyon@fuckup:~$ g++ -o hello hello.cpp
    /usr/bin/ld: crt1.o: No such file: Datei oder Verzeichnis nicht gefunden
    collect2: ld returned 1 exit status
    


  • dann ist Deine g++-Installation kaputt.

    Genau so ist es - wobei das File eigentlich zur glibc gehört. Also installier mal glibc-devel oder libc6-dev oder wie auch immer das heißen mag. Eigentlich sollte das durch die Dependencies automatisch geschehen sein.



  • hab noch nen paar libs install. nun das:

    zyon@fuckup:~$ g++ -o hello hello.cpp
    /usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/crt1.o: In function `_start':
    ../sysdeps/i386/elf/start.S:115: undefined reference to `main'
    collect2: ld returned 1 exit status
    


  • Dann hast du dich entweder bei main vertippt (so schwierig das auch sein mag :D), oder es ist noch viel kaputter als man zuerst denken konnte.



  • nun habe ich bei:

    #include <iostream.h>
    using namespace std;
    
    int main()
    {
        cout << "Hello World!";
        return 0;
    }
    
    zyon@fuckup:~$ gcc -o test main.cc
    /tmp/ccjglEt6.o: In function `main':
    main.cc:(.text+0x25): undefined reference to `std::cout'
    main.cc:(.text+0x2a): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
    /tmp/ccjglEt6.o: In function `__tcf_0':
    main.cc:(.text+0x47): undefined reference to `std::ios_base::Init::~Init()'
    /tmp/ccjglEt6.o: In function `__static_initialization_and_destruction_0(int, int)':
    main.cc:(.text+0x74): undefined reference to `std::ios_base::Init::Init()'
    /tmp/ccjglEt6.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
    collect2: ld returned 1 exit status
    

    Ich versteh es einfach nicht mehr. muss ich wohl mein system killen 😞



  • nun geht es mit

    g++ -o helo main.cc 😃 wieso Danke an alle



  • Mach noch <iostream> aus <iostream**.h**>.



  • nman schrieb:

    Mach noch <iostream> aus <iostream**.h**>.

    habeich schon sonnst geht es auch nicht.

    Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
    

    Ich muss echt mal sagen der gcc/g++ ist ja wirklich am rum zicken.. na ja dann wird mein std halt mehr zum std 😃 gruß auf Göttingen



  • Hey wieso ist der zickig? 😃

    Wenn Deine Installation nur halb komplett ist, war das alles nicht verwunderlich, und deinen Versuch, C++-Programme mit dem C-Compiler zu übersetzen, hast Du selbst schon drangegeben, oder? 😃


Anmelden zum Antworten