Hi people,
I am very new to coding in c++ and dont understand what this error means, google has been little help. Here is my code can you please tell me why when i compile i get the following error
Error:
Code:
[alan@localhost work]$ gcc ldap.c -o ldap
/tmp/ccijpbPB.o(.text+0x1e): In function `main':
: undefined reference to `ldap_init'
/tmp/ccijpbPB.o(.text+0x52): In function `main':
: undefined reference to `ldap_simple_bind_s'
/tmp/ccijpbPB.o(.text+0x6c): In function `main':
: undefined reference to `ldaperr2string'
collect2: ld returned 1 exit status
Code:
Code:
#include <stdio.h>
#include <ldap.h>
#define HOSTNAME "localhost"
#define PORT_NUMBER 389
#define FIND_DN "dc=my-domain,dc=com"
int main( int argc, char **argv )
{
LDAP *ld;
LDAPMessage *result, *e;
BerElement *ber;
char *a;
char **vals;
int i, rc;
/* Get a handle to an LDAP Connection */
if( (ld = ldap_init(HOSTNAME,PORT_NUMBER)) == NULL)
{
perror( "ldap_init");
return (1);
}
/* Bind anonymously to the LDAP Server */
rc = ldap_simple_bind_s (ld,NULL,NULL);
if (rc != LDAP_SUCCESS)
{
fprintf(stderr,"ldap_simple_bind_s: %s\n", ldaperr2string(rc));
return( 1);
}
else
{
printf("Connection Successful");
}
return ( 0 );
}