Go to main content
Oracle® Developer Studio 12.6: C++ User's Guide

Exit Print View

Updated: July 2017

11.3 Related Library Options

The CC driver provides several options to help you use libraries.

  • Use the -l option to specify a library to be linked.

  • Use the -L option to specify a directory to be searched for the library.

  • Use the -mt option compile and link multithreaded code.

  • Use the -xlang option to link Fortran or C99 runtime libraries.

  • Use the –xatomic=[studio|gcc|none] option to specify which atomics support library is linked.

  • Use the -library option to specify the following libraries that are shipped with the Oracle Developer Studio C++ compiler:

    -libstlport, libstlport_dbg
    -libstdcxx (distributed as part of the Oracle Solaris OS)

A library that is specified using both –library and –staticlib options will be linked statically if a static version of the library is available. Some examples:

The following command links the libgc library statically.

example% CC test.cc -library=gc -staticlib=gc

The following command excludes the libraries libCrun and libCstd, which would otherwise be included by default.

example% CC test.cc -library=no%Crun,no%Cstd

By default, CC links various sets of system libraries depending on the command line options. If you specify -xnolib (or -nolib) , CC links only those libraries that are specified explicitly with the -l option on the command line. (When -xnolib or -nolib is used, the -library option is ignored, if present.)

The –R option allows you to build dynamic library search paths into the executable file. At execution time, the runtime linker searches these paths for the shared libraries needed by the application. The CC driver passes one or more –R options pointing into <install-directory>/lib to ld by default if the compiler is installed in the standard location. You can use -norunpath to disable building the default path for shared libraries into the executable.

The linker searches /lib and /usr/lib by default. Do not specify these directories or any compiler installation directories in -L options.

Programs built for deployment should be built with -norunpath or an -R option that avoids looking in the compiler directory for libraries. See Using Shared Libraries.