Next: , Previous: Linking/Windows, Up: General


2.4 Accessing the Library (Solaris)

2.4.1 Accessing the Library under Solaris

If the Solaris 64-bit f95 version of ACML was installed in the default directory, /opt/acml3.6.1/sun64, then the command:

     f95 -xarch=amd64 driver.f -L/opt/acml3.6.1/sun64/lib -lacml

can be used to compile the program driver.f and link it to the ACML.

The ACML Library is supplied in both static and shareable versions, libacml.a and libacml.so, respectively. By default, the commands given above will link to the shareable version of the library, libacml.so, if that exists in the directory specified. Linking with the static library can be forced either by using the compiler flag -Bstatic, e.g.

     f95 -xarch=amd64 driver.f -L/opt/acml3.6.1/sun64/lib -Bstatic -lacml

or by inserting the name of the static library explicitly in the command line, e.g.

     f95 -xarch=amd64 driver.f /opt/acml3.6.1/sun64/lib/libacml.a

Notice that if the application program has been linked to the shareable ACML Library, then before running the program, the environment variable LD_LIBRARY_PATH must be set, for example, by the C-shell command:

     setenv LD_LIBRARY_PATH /opt/acml3.6.1/sun64/lib

where it is assumed that libacml.so was installed in the directory /opt/acml3.6.1/sun64/lib (see the man page for ld(1) for more information about LD_LIBRARY_PATH.).

The command

     f95 -xarch=sse2 driver.f -L/opt/acml3.6.1/sun32/lib -lacml

will compile and link a 32-bit program with a 32-bit ACML.

To compile and link a 64-bit C program with a 64-bit ACML, invoke

     cc -xarch=amd64 -I/opt/acml3.6.1/sun64/include driver.c
         -L/opt/acml3.6.1/sun64/lib -lacml -lfsu -lsunmath -lm

The switch "-I/opt/acml3.6.1/sun64/include" tells the compiler to search the directory /opt/acml3.6.1/sun64/include for the ACML C header file acml.h, which should be included by driver.c. Note that it is necessary to add the Sun compiler run-time libraries -lfsu -lsunmath -lm when linking the program.

If you have an SMP machine and want to take best advantage of it, link against the Solaris OpenMP version of ACML like this:

     f95 -openmp -xarch=amd64 driver.f -L/opt/acml3.6.1/sun64_mp/lib -lacml_mp
     f95 -openmp -xarch=sse2 driver.f -L/opt/acml3.6.1/sun32_mp/lib -lacml_mp

Note that the directories and library names involved now include the suffix _mp.

The -openmp flag is important - it tells f95 to link with the appropriate compiler OpenMP run-time library. Without it you might get an "unresolved symbol" message at link time.

The command

     cc -openmp -xarch=amd64 -I/opt/acml3.6.1/sun64/include driver.c
         -L/opt/acml3.6.1/sun64/lib -lacml_mp -lfsu -lsunmath -lm -lmtsk

will compile driver.c and link it to the 64-bit ACML. Again, the -openmp flag is important if you are linking to the OpenMP version of ACML. The C compiler is instructed to search the directory /opt/acml3.6.1/sun64_mp/include for the ACML C header file acml.h, which should be included by driver.c, by using the switch "-I/opt/acml3.6.1/sun64_mp/include". Note that in the example we add the libraries -lfsu -lsunmath -lm -lmtsk to the link command, so that required compiler run-time libraries are found.