在开发的过程中的有的厂家提供的API,或者其他同事写的功能模块用的是C++语言,而因为我们自己菜或者懒习惯使用python脚本语言开发,这里主要讲解如何使用python调用DLL文件(windows平台)在linux平台中使用的.so文件。
1.创建一个DLL项目
项目会自动生成一个pch.cpp文件,主要的代码就是在这个文件下编写
// 调用其他的函数 // 相机的库 #include "AimPositionAPI.h" #include "AimPositionDef.h" #include <fstream> #pragma comment(lib,"AimPosition2.3.2d.lib") // 使用debug模式下的lib和dll组合
在这个cpp文件下导入厂家或者同事写的c++文件
主要通过这句话让DLL文件能够被外部访问
extern "C" {
__declspec(dllexport) int testDemo();
__declspec(dllexport) void testString(char *name);
}
testString的实现函数如下
#include <fstream