In general FORTRAN compilers append an underscore character ('_') to each user defined symbol. In this way name space conflicts can be avoided between C and FORTRAN. However, the xlf (f77) compiler does not add the trailing underscore to user defined symbols by default.
The FORTRAN GL library supports both naming conventions by exporting symbols with and without appended underscores. Because of a potential name space clash between the FORTRAN and C libraries, some care must be taken when linking together modules that use both the C and FORTRAN bindings for GL subroutines.
Programs written in FORTRAN and using GL fall into one of four categories. The following gives an example from each category, showing how FORTRAN GL applications can be linked.
To link FORTRAN-only source code, enter the following:
xlf -U foof.f -lfgl -lm
This binds the FORTRAN application with the FORTRAN GL library and the Math Library.
To link C and FORTRAN source where GL is referenced only through the FORTRAN interface, enter the following:
xlc -c fooc.c xlf -U foof.f fooc.o -lfgl -lc -lm
This binds the MIXED application with the FORTRAN GL library, the C library, and the Math Library. The C Library is used to resolve externals from the module compiled by the xlc command.
To link C and FORTRAN source where GL is referenced only through the C interface, enter the following
xlf -U -c foof.f xlc fooc.c foof.o -lgl -lxlf -lm
This binds the MIXED application with the C GL library, the XLF library, and the Math Library. The XLF Library is used to resolve externals from the module compiled by the xlf command.
To link C and FORTRAN source where GL is referenced through both the C and FORTRAN interfaces, enter the following:
xlf -U -qextname -c foof.f xlc -c fooc.c xlc foof.o fooc.o -lgl -lc -lfgl -lxlf -lm
This creates the MIXED application. By compiling the FORTRAN modules with the -qextname flag, the extended naming rules are enforced. The extended naming rules append an underscore to all user-defined symbols.