.. include:: ../substitutions

.. oe:namespace:: OEConfGen

.. meta::
   :keywords: OEAddGlobalFragLib

.. oe:function:: OEAddGlobalFragLib

   .. oe:language:: c++ java csharp

      .. oe:api::

         bool OEAddGlobalFragLib(const std::string& fraglib_filename,
                                 bool replace = true)

   .. oe:language:: python

      .. oe:api:: python

         OEAddGlobalFragLib(fraglib_filename: str, replace: bool = True) -> bool


   Adds a fragment library located at *fraglib_filename* to **Omega**'s
   global fragment library.  If *replace* is true, previously
   existing fragments in the current global fragment library are replaced
   with the ones from *fraglib_filename*.

   Unlike the fragment libraries loaded by
   :oe:meth:`OEConfGen::OEOmega::AddFragLib`, the global fragment
   library is accessible to all **Omega** instances.  It is most useful in
   the Java programming language to minimize memory usage when
   running multiple :ref:`OEOmega <OEConfGen_OEOmega>` instances in threads.
   Other languages have the default fragment library preloaded.


   If you use :oe:func:`OEConfGen::OEAddGlobalFragLib`
   to load your fragment library,
   do not use :oe:meth:`OEConfGen::OEOmega::AddFragLib`, as this
   will load the fragment library only into that particular
   :ref:`OEOmega <OEConfGen_OEOmega>` instance.

   .. note::

      This function is not thread-safe and must be called before
      starting any threads.

   .. seealso::

      * :oe:func:`OEConfGen::OEClearGlobalFragLib` function
