4.2.1. Linking Application with AOCL-BLAS - 5.2 English - 57404

AOCL User Guide (57404)

Document ID
57404
Release Date
2025-12-29
Version
5.2 English

The AOCL-BLAS library can be linked statically or dynamically with the user application. It has a separate binary for single-threaded and multi-threaded implementation.

The basic build command is as following:

$ gcc test_blis.c -I<path-to-AOCL-BLAS-header> <link-options> \
  -o test_blis.x

The following table explains different options depending on a particular build configuration:

Table 4.7 AOCL-BLAS Application - Link Options#

Application Type

Linking Type

Link Options

Single-threaded

Static

<path-to-AOCL-BLAS-library>/libblis.a -lm -lpthread

Single-threaded

Dynamic

-L<path-to-AOCL-BLAS-library> -lblis -lm -lpthread

Multi-threaded

Static

<path-to-AOCL-BLAS-library>/libblis-mt.a -lm -fopenmp

Multi-threaded

Dynamic

-L<path-to-AOCL-BLAS-library> -lblis-mt -lm -fopenmp

Example - Dynamic Linking and Execution

AOCL-BLAS can be built as a shared library. By default, the library is built as both static and shared libraries. Complete the following steps to build a shared lib version of AOCL-BLAS and link it with the user application:

  1. During configuration, enable the support for the shared lib using the following command:

    $ ./configure --disable-static --enable-shared zen
    
  2. Link the application with the generated shared library using the following command:

    $ gcc CBLAS_DGEMM_usage.c -I /path/to/include/aocl-blas/ \
      -L/path/to/libblis.so -lblis -lm -lpthread -o CBLAS_DGEMM_usage.x
    
  3. Ensure that the shared library is available in the library load path. Run the application using the following command (for this demo we will use the CBLAS_DGEMM_usage.c):

    $ export LD_LIBRARY_PATH="/path/to/libblis.so"
    $ ./CBLAS_DGEMM_usage.x
    a =
    1.000000 2.000000
    3.000000 4.000000
    b =
    5.000000 6.000000
    7.000000 8.000000
    c =
    19.000000   22.000000
    43.000000   50.000000
    

The same header can be used for both static and shared libraries on Windows. To access DLL’s public data symbols and objects, you can define BLIS_EXPORT=declspec(dllimport) to import those symbols explicitly. Importing is not required for:

  • The AOCL-BLAS and CBLAS interface users

  • Most of the cases where BLIS interface is used