Visible to Intel only — GUID: GUID-5CEDE1B0-52CD-4C92-9C1F-D7B234D81A21
Visible to Intel only — GUID: GUID-5CEDE1B0-52CD-4C92-9C1F-D7B234D81A21
Manage Libraries
Manage 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. Add the location of your static libraries to the LIBRARY_PATH environment variable so that they are available for linking during compilation.
For example, to compile file.cpp and link it with the library lib.a, located in the /libs directory:
Add the directory /libs to LIBRARY_PATH from the command line with the export command:
export LIBRARY_PATH=/libs:$LIBRARY_PATH
Alternately, add the directory to LIBRARY_PATH by addiing the export command to your startup file.
Compile file.cpp and link it with lib.a:
icc file.cpp lib.a
To link your library during compilation without modifying the LIBRARY_PATH environment variable use the -L option. For example:
icc file.cpp -L /libs lib.a
During compilation, the compiler passes object files to the linker in the following order:
Object files, from files specified on the command line, in the order they are specified (left to right)
Objects or libraries specified in default configuration files
Default Intel and system libraries
For example, the command
icc lib1.a file.cpp lib2.awould have the following link order:
- lib1.a
- file.o
- lib2.a
- Objects or libraries specified in default configuration files
- Default Inel and system libraries
Manage 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 you can specify the library name on the command line. For example, to compile file.cpp and link it with the library mylib.lib enter the command:
icc file.cpp mylib.lib
Other Considerations
The Intel Compiler Math Libraries contain performance-optimized implementations for various Intel platforms. By default, the best implementation for the underlying hardware is selected at runtime. The library dispatch of multi-threaded code may lead to apparent data races, which may be detected by certain software analysis tools. However, as long as the threads are running on cores with the same CPUID, these data races are harmless and are not a cause for concern.