我的proj1.dll它依赖于另一个 DLL proj2.dll,. 我是proj1.dll针对VS2013中编译时编译器输出的导入库进行编译的proj2.dll。我还导出了我有兴趣使用的公共函数。所以现在我有两个独立的 DLL,它们都符合“cdll”标准。
我想在 Python 中使用proj1.dll,但遇到以下问题:
import ctypes
# Crashes saying no entry point for "some_func" in proj2.dll
ctypes.cdll.LoadLibrary("C:\myfolder\proj1.dll")
ctypes.cdll.LoadLibrary("C:\myfolder\proj2.dll") # Loads fine
ctypes.cdll.LoadLibrary("C:\myfolder\proj1.dll") # Loads fine if proj2 is loaded first
Run Code Online (Sandbox Code Playgroud)
以前,当我构建proj2为静态库并在proj1. 这两个 DLL 存在于同一文件夹中。我什至尝试将文件夹的路径添加到我的 PATH 环境变量中,以查看这是否是路径问题,但没有任何改变。
我假设 Windows 将加载proj1.dll然后加载 dll 的依赖项。我错了吗?调用者(Python)是否必须首先加载依赖DLL?有谁知道为什么会发生这种情况?
我的应用程序中有两个线程.一个将值放在a中Queue,另一个将它们从中Queue处理并处理它们.
关闭应用程序时,我面临两难选择.处理中的项目的线程Queue被卡住:
item = request_queue.get() # this call blocks until an item is available
Run Code Online (Sandbox Code Playgroud)
唯一能够终止线程的是如果另一个项被添加到Queue- 并且由于主线程没有添加任何东西(因为它正在关闭),应用程序会锁定.
那么...... Queue.get()即使什么都没有,我怎么能指示以某种方式返回Queue呢?
我在 DLL 中有一个类,它有一个我想从外部调用但不公开类本身的方法。假设我有以下课程:
// MyClass.h
class MyClass
{
public:
// ...
void SetNumber(int x);
private:
int _number;
};
// MyClass.cpp
// ...
MyClass::SetNumber(int x)
{
_number = x;
}
Run Code Online (Sandbox Code Playgroud)
我想创建 MyClass 的一个实例并在 DLL 的整个生命周期中使用它。
// main.cpp
#define EXTERN extern "C" __declspec( dllexport )
int APIENTRY WinMain(/* ... */)
{
MyClass * myclass = new MyClass(); // I need to use this instance
// everytime in the exported SetNumber function.
return 0;
}
void EXTERN SetNumber(int x)
{
// Get myclass …Run Code Online (Sandbox Code Playgroud)