lib_handler.h 920 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef LIB_HANDLER_H
  2. #define LIB_HANDLER_H
  3. #include "glob_opts.h"
  4. #ifdef IS_WINDOWS
  5. #include <windows.h>
  6. typedef HINSTANCE soHandle_t;
  7. #else
  8. #include <unistd.h>
  9. #include <dlfcn.h>
  10. typedef void *soHandle_t;
  11. #endif
  12. #ifdef IS_WINDOWS
  13. #define SHAREDLIBEXT "dll"
  14. #elif defined IS_MAC
  15. #define SHAREDLIBEXT "dylib"
  16. #else
  17. #define SHAREDLIBEXT "so"
  18. #endif
  19. // NB: A shared library should be put into the shared library search path:
  20. // Linux: LD_LIBRARY_PATH
  21. // Mac OSX: DYLD_LIBRARY_PATH
  22. // Windows: PATH
  23. /** Loads a dynamically linked library.
  24. * @param libname The name of the library to load.
  25. * @return Shared library handle, or OSQP_NULL if failure.
  26. */
  27. soHandle_t lh_load_lib(const char* libname);
  28. /** Unloads a shared library.
  29. * @param libhandle Handle of shared library to unload.
  30. * @return Zero on success, nonzero on failure.
  31. */
  32. c_int lh_unload_lib(soHandle_t libhandle);
  33. #endif /*LIB_HANDLER_H*/