Pixar Arch 0.25.8
Loading...
Searching...
No Matches
library.h
Go to the documentation of this file.
1// Copyright 2016 Pixar
2//
3// Licensed under the terms set forth in the LICENSE.txt file available at
4// https://openusd.org/license.
5//
6// Modified by Jeremy Retailleau.
7
8#ifndef PXR_ARCH_LIBRARY_H
9#define PXR_ARCH_LIBRARY_H
10
11#include "pxr/arch/pxr.h"
12#include "pxr/arch/api.h"
13
14#include <string>
15
16#if defined(ARCH_OS_WINDOWS)
17# define ARCH_LIBRARY_LAZY 0
18# define ARCH_LIBRARY_NOW 0
19# define ARCH_LIBRARY_LOCAL 0
20# define ARCH_LIBRARY_GLOBAL 0
21# define ARCH_LIBRARY_SUFFIX ".dll"
22# define ARCH_STATIC_LIBRARY_SUFFIX ".lib"
23#else
24# include <dlfcn.h>
25# define ARCH_LIBRARY_LAZY RTLD_LAZY
26# define ARCH_LIBRARY_NOW RTLD_NOW
27# define ARCH_LIBRARY_LOCAL RTLD_LOCAL
28# define ARCH_LIBRARY_GLOBAL RTLD_GLOBAL
29# if defined(ARCH_OS_DARWIN)
30# define ARCH_LIBRARY_SUFFIX ".dylib"
31# else
32# define ARCH_LIBRARY_SUFFIX ".so"
33# endif
34# define ARCH_STATIC_LIBRARY_SUFFIX ".a"
35#endif
36
37// On MacOS shared libraries and loadable modules (aka loadable bundles aka
38// plugins) are different entities. Most cross-platform software packages
39// that create loadable modules use .so as the extension on MacOS for
40// compatibility, so we use that here.
41#if defined(ARCH_OS_DARWIN)
42# define ARCH_PLUGIN_SUFFIX ".so"
43#else
44# define ARCH_PLUGIN_SUFFIX ARCH_LIBRARY_SUFFIX
45#endif
46
47ARCH_NAMESPACE_OPEN_SCOPE
48
51
56ARCH_API
57void* ArchLibraryOpen(const std::string &filename, int flag);
58
61ARCH_API
62std::string ArchLibraryError();
63
65ARCH_API
66int ArchLibraryClose(void* handle);
67
73ARCH_API
74void* ArchLibraryGetSymbolAddress(void* handle, const char* name);
75
76ARCH_NAMESPACE_CLOSE_SCOPE
77
78#endif // PXR_ARCH_LIBRARY_H
int ArchLibraryClose(void *handle)
Closes an object opened with ArchLibraryOpen.
void * ArchLibraryOpen(const std::string &filename, int flag)
library.h Architecture dependent loading and unloading of dynamic libraries.
void * ArchLibraryGetSymbolAddress(void *handle, const char *name)
Obtain the address of a symbol defined within an object opened with ArchLibraryOpen.
std::string ArchLibraryError()
Obtain a description of the most recent error that occurred from ArchLibraryOpen.