Kompilationsfehler bei ner IRC Klasse



  • Hi leute,

    Bin Anfänger in C++ und wollte mal eine Klasse machen.. jetzt gibts aber da nen Fehler, bei dem ich überhaupt gar nich weiss was machen *g*

    Verwende gcc..

    /tmp/ccJjVI3N.o(.text+0xb7): In function `__static_initialization_and_destruction_0(int, int)':
    : undefined reference to `std::ios_base::Init::Init[in-charge]()'
    /tmp/ccJjVI3N.o(.text+0xe8): In function `__tcf_0':
    : undefined reference to `std::ios_base::Init::~Init [in-charge]()'
    /tmp/ccJjVI3N.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
    collect2: ld returned 1 exit status
    

    Hier meine Klasse

    #include <sys/socket.h>
    #include <sys/types.h>
    #include <netdb.h>
    #include <netinet/in.h>
    #include <arpa/inet.h>
    
    class IRCclass {
      private:
        int s;
        int bytes;
        char buffer[1024];    
        struct sockaddr_in srv;
      public:  
        int socketConnect(char *host, char *port) {
          s=socket(AF_INET,SOCK_STREAM,0);
          if (s == -1)
          {
            perror("socket() failed");
            return 1;	
          }  
    
          srv.sin_addr.s_addr = inet_addr(host);
          srv.sin_port = htons((unsigned short int) atol(port));
          srv.sin_family = AF_INET;
    
          if(connect(s, (sockaddr *) &srv, sizeof(srv)) == -1) 
          {
            perror("connect() failed");
            return 2;
          }
        }
    
        void disConnect()
        {
        	close(s);
        }
    
        int parseLine()
        {      
          bytes = recv(s, buffer, sizeof(buffer) - 1, 0);
            buffer[bytes] = '\0';
            printf("%s", buffer);
    
          return 0;
        }
    
        int sendRaw(char *text)
        {
          send(s,text,strlen(text),0);
    
          return 0;
        }
    };
    

    und das file mit dem ich das ganze aufrufe..

    #include <iostream>
    #include "lib/irc.h"
    
    int main(int argc, char *argv[])
    {
      int run;
    
      if(argc != 3)
      {
        fprintf(stderr, "usage %s host port\n", argv[0]);
        return 1;
      }
    
      IRCclass IRC;
    
      IRC.socketConnect(argv[1],argv[2]);
    
      run = 1;
      while(run)
      {
        IRC.parseLine();
      }
    }
    

    weiss jemand Rat? Und evtl noch generelle Verbesserungen?

    Thx vielmals

    Gruss
    mix



  • Dieser Thread wurde von Moderator/in HumeSikkins aus dem Forum C++ in das Forum Compiler-Forum verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.



  • hallo

    hast du g++ benutzt?

    könnte es sein, dass du es in c kompiliert hast, sprich gcc?

    teste g++.



  • oh ja.. genau .. 😃 thx jetzt gehts.. (oh mann was fürn dummer fehler *g*)



  • normal.


Anmelden zum Antworten