2
我想从DLL加载特定函数并将其存储在Boost函数中。这可能吗?C++将函数从DLL加载到Boost函数中
typedef void (*ProcFunc) (void);
typedef boost::function<void (void)> ProcFuncObj;
ACE_SHLIB_HANDLE file_handle = ACE_OS::dlopen("test.dll", 1);
ProcFunc func = (ProcFunc) ACE_OS::dlsym(file_handle, "func1");
ProcFuncObj fobj = func; //This compiles fine and executes fine
func(); //executes fine
fobj(); //but crashes when called
谢谢, Gokul。
我喜欢你在同一句子中如何使用“执行正常”和“崩溃”;) –
你能确认'func'不是null吗? –
实际上,我的意思是当它被称为fobj()时崩溃,在下一句 – Gokul