[gnet-devel] GNet, compile errors.



Hello,
I installed GNet library and i'm using Code::Blocks. I have got errors
in compile my programs from examples. Help me in use GNet, please.

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <glib.h>
#include <gnet.h>


int main()
{
   gnet_init();
   //nasz gniazdko
   GUdpSocket *mysocket = NULL;
   GInetAddr *addr = NULL;
   mysocket = gnet_udp_socket_new();
   addr = gnet_inetaddr_new("www.schat.hopto.net/",1323);
   gchar bufor[1024];
   gint zapis_l;
   do
   {
        //odbior
        zapis_l =gnet_udp_socket_receive(mysocket, bufor,
sizeof(bufor), &addr);
        //wyswietlanie
        std::cout<<"Odebrano"<<zapis_l;
   }while(zapis_l = 0);

 gnet_inetaddr_delete (addr);
 gnet_udp_socket_delete (mysocket);
}





ERRORS:

-------------- Build: Release in schat ---------------

Compiling: main.cpp
In file included from ../../MinGW/include/GNet_source/gnet.h:26,
                from
C:\CodeBlocks\cwiczenia_rozne_smieci\client_gnet\main.cpp:7:
../../MinGW/include/GNet_source/gnetconfig.h:16:26: warning: no
newline at end of file
Linking console executable: bin\Release\schat.exe
obj\Release\main.o:main.cpp:(.text+0x20): undefined reference to `_gnet_init'
obj\Release\main.o:main.cpp:(.text+0x2b): undefined reference to
`_gnet_udp_socket_new'
obj\Release\main.o:main.cpp:(.text+0x42): undefined reference to
`_gnet_inetaddr_new'
obj\Release\main.o:main.cpp:(.text+0x6d): undefined reference to
`_gnet_udp_socket_receive'
obj\Release\main.o:main.cpp:(.text+0xb3): undefined reference to
`_gnet_inetaddr_delete'
obj\Release\main.o:main.cpp:(.text+0xbb): undefined reference to
`_gnet_udp_socket_delete'
obj\Release\main.o:main.cpp:(.text+0xde): undefined reference to
`_gnet_inetaddr_delete'
obj\Release\main.o:main.cpp:(.text+0xe6): undefined reference to
`_gnet_udp_socket_delete'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 6 seconds)
8 errors, 1 warnings












I have got errors in the example code too:
-code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gnet.h>       /* Or <gnet/gnet.h> when installed. */

typedef enum { NORMAL} ClientType;


static void usage (int status);

static void normal_echoclient (gchar* hostname, gint port);


int
main(int argc, char** argv)
{
 ClientType client_type = NORMAL;

 gnet_init ();

 if (argc != 3)
   usage(EXIT_FAILURE);

 switch (client_type)
   {
   case NORMAL:
     g_print ("Normal echo client running\n");
     normal_echoclient(argv[argc-2], atoi(argv[argc-1]));
     break;
   default:
     g_assert_not_reached();
   }

 return 0;
}


static void
usage (int status)
{
 g_print ("usage: echoclient-udp <server> <port>\n");
 exit(status);
}



/* ************************************************************ */


static void
normal_echoclient(gchar* hostname, gint port)
{
 GInetAddr* addr = NULL;
 GUdpSocket* socket = NULL;
 gchar buffer[1024];
 guint n;

 /* Create the address */
 addr = gnet_inetaddr_new (hostname, port);
 g_assert (addr != NULL);

 /* Create the socket */
 socket = gnet_udp_socket_new();
 g_assert (socket != NULL);

 while (fgets(buffer, sizeof(buffer), stdin) != 0)
   {
     GUdpPacket* packet;
     gint rv;

     /* Create packet */
     n = strlen(buffer);
     packet = gnet_udp_packet_send_new (buffer, n, addr);

     /* Send packet */
     rv = gnet_udp_socket_send(socket, packet);
     g_assert (rv == 0);
     gnet_udp_packet_delete (packet);

     /* Receive packet */
     packet = gnet_udp_packet_receive_new (buffer, sizeof(buffer));
     n = gnet_udp_socket_receive (socket, packet);
     if (n == 0) break;
     gnet_inetaddr_delete (packet->addr);
     gnet_udp_packet_delete (packet);

     /* Write out */
     fwrite(buffer, n, 1, stdout);
   }

 gnet_inetaddr_delete (addr);
 gnet_udp_socket_delete (socket);
}




-ERRORS


-------------- Build: Release in schat ---------------

Compiling: main.cpp
In file included from ../../MinGW/include/GNet_source/gnet.h:26,
                from
C:\CodeBlocks\cwiczenia_rozne_smieci\client_gnet\main.cpp:7:
../../MinGW/include/GNet_source/gnetconfig.h:16:26: warning: no
newline at end of file
Linking console executable: bin\Release\schat.exe
obj\Release\main.o:main.cpp:(.text+0x20): undefined reference to `_gnet_init'
obj\Release\main.o:main.cpp:(.text+0x2b): undefined reference to
`_gnet_udp_socket_new'
obj\Release\main.o:main.cpp:(.text+0x42): undefined reference to
`_gnet_inetaddr_new'
obj\Release\main.o:main.cpp:(.text+0x6d): undefined reference to
`_gnet_udp_socket_receive'
obj\Release\main.o:main.cpp:(.text+0xb3): undefined reference to
`_gnet_inetaddr_delete'
obj\Release\main.o:main.cpp:(.text+0xbb): undefined reference to
`_gnet_udp_socket_delete'
obj\Release\main.o:main.cpp:(.text+0xde): undefined reference to
`_gnet_inetaddr_delete'
obj\Release\main.o:main.cpp:(.text+0xe6): undefined reference to
`_gnet_udp_socket_delete'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 12 seconds)
8 errors, 1 warnings












I had other codes, and i remember i had got error with no class "GUdpPacket".
Please, help me in compile programs.

Best regards, Peter.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]