Код: Выделить всё
#pragma once
#include
#include
#if defined _MSC_VER || defined __MINGW32__
#ifdef __cplusplus
#define API extern "C" __declspec(dllexport)
#else
#define API __declspec(dllexport)
#endif
#else
#ifdef __cplusplus
#define API extern "C" __attribute__((visibility("default")))
#else
#define API __attribute__((visibility("default")))
#endif
#endif
API void* construct(const char* initString);
Код: Выделить всё
#include
#include
#include
#include
typedef void* (ConstructT)(const char*);
int main() {
boost::function constructFunc = boost::dll::import_alias(
"TestPluginDll.dll",
"construct",
boost::dll::load_mode::append_decorations | boost::dll::load_mode::load_with_altered_search_path
);
std::string initArg = "hello";
void* pluginInstance = constructFunc(initArg.c_str());
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79090291/access-violation-exception-when-calling-dll-function-loaded-with-boost-import-al[/url]