apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gaurav Gupta" <gaurav.gg.gu...@oracle.com>
Subject How to use the sockets library of apr?
Date Thu, 30 Sep 2004 11:23:02 GMT
Hi,

Am getting this error when creating executable for my code for a socket
server programme. Kindly help.

ERRRORS:
/tmp/cc8HZXkf.o(.text+0x1b): In function `main':
: undefined reference to `apr_pool_create_ex'
/tmp/cc8HZXkf.o(.text+0x48): In function `main':
: undefined reference to `apr_sockaddr_info_get'
/tmp/cc8HZXkf.o(.text+0x74): In function `main':
: undefined reference to `apr_socket_create'
/tmp/cc8HZXkf.o(.text+0x95): In function `main':
: undefined reference to `apr_socket_bind'
/tmp/cc8HZXkf.o(.text+0xb5): In function `main':
: undefined reference to `apr_socket_listen'
collect2: ld returned 1 exit status

LIBRARIES INCLUDED:
-L/home/gauragup/apache/lib/libapr-1.a -L/home/gauragup/apache/lib/libapr-1.
1a

CODE:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/unistd.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
#include "apr_pools.h"
#include "apr_thread_proc.h"
#include "apr_network_io.h"
#include "apr_errno.h"
#include "apr_general.h"
#include "apr_lib.h"
#include "apr_strings.h"

main() {
    apr_status_t rv;
    apr_sockaddr_t *sa;
    apr_socket_t *sock;

    apr_pool_t *p;
    apr_pool_create(&p, NULL);
    printf("Pool created /n");

    apr_sockaddr_info_get(&sa, NULL, APR_INET, 8021, 0, p);
    printf("Got the addres /n");

    apr_socket_create(&sock, sa->family, SOCK_STREAM, APR_PROTO_TCP, p);
    printf("Socket created /n");

    apr_socket_bind(sock, sa);
    printf("Socket bound /n");

    rv = apr_socket_listen(sock, 5);
}





Mime
View raw message