All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
library.h
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_BASE_ARCH_LIBRARY_H
8#define PXR_BASE_ARCH_LIBRARY_H
9
10#include "pxr/pxr.h"
11#include "pxr/base/arch/api.h"
12
13#include <string>
14
15#if defined(ARCH_OS_WINDOWS)
16# define ARCH_LIBRARY_LAZY 0
17# define ARCH_LIBRARY_NOW 0
18# define ARCH_LIBRARY_LOCAL 0
19# define ARCH_LIBRARY_GLOBAL 0
20# define ARCH_LIBRARY_SUFFIX ".dll"
21# define ARCH_STATIC_LIBRARY_SUFFIX ".lib"
22#else
23# include <dlfcn.h>
24# define ARCH_LIBRARY_LAZY RTLD_LAZY
25# define ARCH_LIBRARY_NOW RTLD_NOW
26# define ARCH_LIBRARY_LOCAL RTLD_LOCAL
27# define ARCH_LIBRARY_GLOBAL RTLD_GLOBAL
28# if defined(ARCH_OS_DARWIN)
29# define ARCH_LIBRARY_SUFFIX ".dylib"
30# else
31# define ARCH_LIBRARY_SUFFIX ".so"
32# endif
33# define ARCH_STATIC_LIBRARY_SUFFIX ".a"
34#endif
35
36// On MacOS shared libraries and loadable modules (aka loadable bundles aka
37// plugins) are different entities. Most cross-platform software packages
38// that create loadable modules use .so as the extension on MacOS for
39// compatibility, so we use that here.
40#if defined(ARCH_OS_DARWIN)
41# define ARCH_PLUGIN_SUFFIX ".so"
42#else
43# define ARCH_PLUGIN_SUFFIX ARCH_LIBRARY_SUFFIX
44#endif
45
46PXR_NAMESPACE_OPEN_SCOPE
47
51
57ARCH_API
58void* ArchLibraryOpen(const std::string &filename, int flag);
59
63ARCH_API
64std::string ArchLibraryError();
65
68ARCH_API
69int ArchLibraryClose(void* handle);
70
77ARCH_API
78void* ArchLibraryGetSymbolAddress(void* handle, const char* name);
79
80PXR_NAMESPACE_CLOSE_SCOPE
81
82#endif // PXR_BASE_ARCH_LIBRARY_H
ARCH_API std::string ArchLibraryError()
Obtain a description of the most recent error that occurred from ArchLibraryOpen.
ARCH_API int ArchLibraryClose(void *handle)
Closes an object opened with ArchLibraryOpen.
ARCH_API void * ArchLibraryGetSymbolAddress(void *handle, const char *name)
Obtain the address of a symbol defined within an object opened with ArchLibraryOpen.
ARCH_API void * ArchLibraryOpen(const std::string &filename, int flag)
library.h Architecture dependent loading and unloading of dynamic libraries.