MCPcopy Create free account
hub / github.com/VCVRack/Rack / loadPluginCallback

Function loadPluginCallback

src/plugin.cpp:98–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96typedef void (*InitCallback)(Plugin*);
97
98static InitCallback loadPluginCallback(Plugin* plugin) {
99 // Load plugin library
100 std::string libraryExt;
101#if defined ARCH_LIN
102 libraryExt = "so";
103#elif defined ARCH_WIN
104 libraryExt = "dll";
105#elif defined ARCH_MAC
106 libraryExt = "dylib";
107#endif
108
109 std::string libraryFilename = "plugin." + libraryExt;
110 std::string libraryPath = system::join(plugin->path, libraryFilename);
111
112 // Check file existence
113 if (!system::isFile(libraryPath))
114 throw Exception("Plugin binary not found at %s", libraryPath.c_str());
115
116 // Load dynamic/shared library
117 plugin->handle = loadLibrary(libraryPath);
118
119 // Get plugin's init() function
120 InitCallback initCallback = (InitCallback) getSymbol(plugin->handle, "init");
121 if (!initCallback)
122 throw Exception("Failed to read init() symbol in %s", libraryPath.c_str());
123
124 return initCallback;
125}
126
127
128/** If path is blank, loads Core */

Callers 1

loadPluginFunction · 0.85

Calls 5

isFileFunction · 0.85
ExceptionClass · 0.85
loadLibraryFunction · 0.85
getSymbolFunction · 0.85
joinFunction · 0.70

Tested by

no test coverage detected