Managing Libraries on Linux* and macOS*

During compilation, the compiler reads the LIBRARY_PATH environment variable for static libraries it needs to link when building the executable. At runtime, the executable will link against dynamic libraries referenced in the LD_LIBRARY_PATH environment variable.


If you want to add a directory, /libs for example, to the LIBRARY_PATH, you can do either of the following:

  • command line: prompt> export LIBRARY_PATH=/libs:$LIBRARY_PATH

  • startup file: export LIBRARY_PATH=/libs:$LIBRARY_PATH

To compile file.cpp and link it with the library mylib.a, enter the following command:

icpc file.cpp mylib.a     //on Linux* and macOS*

The compiler passes file names to the linker in the following order:

  1. the object file.

  2. any objects or libraries specified at the command line, in a response file, or in a configuration file.

  3. the Intel® Math Library, libimf.a.

By default, the Intel® C++ Compiler uses the GNU* implementation of the C++ Standard Library (libstdc++) on OS* X v10.8, and libc++ implementation on OS* X v10.9. You can change the default using the -stdlib option:

-stdlib=libc++     //to switch to libc++
-stdlib=libstdc++       //to switch to libstdc++

Managing Libraries on Windows*

The LIB environment variable contains a semicolon-separated list of directories in which the Microsoft* linker will search for library (.lib) files. The compiler does not specify library names to the linker, but includes directives in the object file to specify the libraries to be linked with each object.

For more information on adding library names to the response file and the configuration file, see Using Response Files and Using Configuration Files.

To specify a library name on the command line, you must first add the library's path to the LIB environment variable. Then, to compile file.cpp and link it with the library mylib.lib, enter the following command:

icl file.cpp mylib.lib
Para obtener información más completa sobre las optimizaciones del compilador, consulte nuestro Aviso de optimización.