Программы на C++. Форум разработчиков
Anonymous
Исключение нарушения прав доступа при вызове функции DLL, загруженной с помощью boost import_alias
Сообщение
Anonymous » 16 окт 2024, 01:39
Я пытаюсь вызвать функцию из DLL. API для DLL выглядит следующим образом:
Код: Выделить всё
#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);
Я загружаю вызов этой функции с помощью boost, а затем пытаюсь вызвать ее:
Код: Выделить всё
#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]
1729031941
Anonymous
Я пытаюсь вызвать функцию из DLL. API для DLL выглядит следующим образом: [code]#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); [/code] Я загружаю вызов этой функции с помощью boost, а затем пытаюсь вызвать ее: [code]#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]