HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
library.h
Go to the documentation of this file.
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 
47 
48 /// library.h
49 /// Architecture dependent loading and unloading of dynamic libraries.
50 /// \ingroup group_arch_SystemFunctions
51 
52 /// Load an executable object file.
53 /// \ingroup group_arch_SystemFunctions
54 ///
55 /// Opens the dynamic library that is specified by filename.
56 /// Returning the handle to the module if successful; false otherwise.
57 ARCH_API
58 void* ArchLibraryOpen(const std::string &filename, int flag);
59 
60 /// Obtain a description of the most recent error that occurred from
61 /// \c ArchLibraryOpen.
62 ///\ingroup group_arch_SystemFunctions
64 std::string ArchLibraryError();
65 
66 /// Closes an object opened with \c ArchLibraryOpen.
67 /// \ingroup group_arch_SystemFunctions
69 int ArchLibraryClose(void* handle);
70 
71 /// Obtain the address of a symbol defined within an object opened with
72 /// \c ArchLibraryOpen.
73 /// \ingroup group_arch_SystemFunctions
74 ///
75 /// Obtain the address of a symbol that is specified by name.
76 /// Returning the address of the symbol if successful; nullptr otherwise.
78 void* ArchLibraryGetSymbolAddress(void* handle, const char* name);
79 
81 
82 #endif // PXR_BASE_ARCH_LIBRARY_H
GT_API const UT_StringHolder filename
ARCH_API int ArchLibraryClose(void *handle)
GLuint const GLchar * name
Definition: glcorearb.h:786
ARCH_API void * ArchLibraryGetSymbolAddress(void *handle, const char *name)
PXR_NAMESPACE_OPEN_SCOPE ARCH_API void * ArchLibraryOpen(const std::string &filename, int flag)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
#define ARCH_API
Definition: api.h:23
ARCH_API std::string ArchLibraryError()