Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用适用于 Visual Studio (PTVS) 的 Python 工具。我无法对扩展进行 c++ 调试。我已经启用了本机代码调试。我的疑问是如何链接 2 个项目(c++ 和 python)?在python(3.4 - 64bit)中以这种方式加载c++库:
cpplib = ctypes.cdll.LoadLibrary(CPPLIB_PATH)
这是我从 Visual Studio看到的
如果您只是使用 ctypes 来加载通用的本机(非 Python 感知)DLL,那么这里不需要做任何特别的事情。您可能想要做的唯一一件事是将 Python 项目中的项目引用添加到 C++ 项目中,以便在运行 Python 应用程序时将 C++ 构建为依赖项。
唯一需要注意的是确保 ctypes 可以在运行时找到 DLL。如果您只想按名称引用库,您可能希望将 C++ 项目的最终输出路径设置在您的 .py 文件旁边。