Compiling, linking, and running a program

The LDAP API is supplied in a C DLL that is loaded at program run time, enabling a program to call the functions of the interface. The following rules apply to compiling and link-editing programs that use the LDAP API.

Rules

  1. Include the ldap.h header file in all C or C++ source files that make calls to the LDAP API. If you use SSL/TLS, you must include the ldapssl.h include file after the ldap.h include file.
  2. When compiling, specify -Wc,DLL on the compile of all modules that make calls to the LDAP API.
  3. When linking the program, specify -Wl,DLL and include an LDAP sidefile as one of the files to be linked with the program. The LDAP sidefiles are:
    • /usr/lib/GLDCLDAP.x for 31-bit applications
    • /usr/lib/GLDCLD64.x for 64-bit applications
  4. Ensure that your application has POSIX(ON) so it can use the LDAP API.
  5. When running the program, ensure that the LDAP DLL is accessible. The DLL is supplied in the SYS1.SIEALNKE data set.
    • The 31-bit DLL is GLDCLDAP.
    • The 64-bit DLL is GLDCLD64.
  6. Call the setlocale() routine to set the current locale before the first call to an LDAP API.
  7. If you are using SSL/TLS or Kerberos authentication, you must use the SYS1.SIEALNKE data set.

Makefile and README files are shipped in /usr/lpp/ldap/examples to explain how to build the LDAP sample applications. You might be able to use this information as a base for building your LDAP application.

Using TSO and batch jobs

If you are using TSO and batch jobs to compile, link, and run LDAP client applications, you must be aware of the following additional information:
  • Data set GLDHLQ.SGLDHDRC contains the LDAP header files.
  • Data set GLDHLQ.SGLDEXPC contains the sidefiles.
  • POSIX(ON) must be specified as a runtime option because the default for this environment is POSIX(OFF).