ProgrammerGuideChapter5

From OPeNDAP Documentation
Revision as of 13:35, 26 January 2008 by Yuan (talk | contribs) (→‎Linking Your Program)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
⧼opendap2-jumptonavigation⧽

Linking Your Program

To link a user program to the OPeNDAP client-library version of a data access API library, you need only substitute the name of the reimplemented API library for the original, and add the OPeNDAP Data Access Protocol library (libdap++) to the link list.

Because the DAP library and the API have circular dependencies they must each be included on the linker command line twice. An example of this can be seen in the OPeNDAP-NetCDF Makefile; the value of LIBS is passed to the linker ld. Note that the API library is listed first.


LIBS = -lnc-dods -ldap++ -lnc-dods -ldap++

You should have users link their programs using gcc or g++ since the libraries are all built using those tools. In particular, g++ includes libstdc++ (and libg++) by default when it builds an executable program from object modules. If you use gcc instead of g++ when you link, be sure to include these libraries as well after all the libraries listed above. If you don't use gcc, but instead use the linker directly (i.e, you call ld yourself) you are on your own - you can use gcc -V to determine what flags and additional libraries it uses that are specific to your system and then experiment with those. We cannot tell you how to proceed since each UNIX variant requires different flags and libraries.