So I'm trying to import some function contained in a .lib file into Python to build an SDK that will allow me to talk to some special hardware components. I read online that it is not really easy to import a .lib file into Python:
Static library (.lib) to Python project
So I'm trying to build a dll using the .lib and its corresponding .h file. I don't have access to the .lib source code. All I have access to is the .h file. I've looked online and found this:
Converting static link library to dynamic dll
Since I'm building the DLL for Python I can't use the .def file. I tried directly just importing the .h and .lib file into a project and creating a dll file but the functions were not implemented. So I tried making a separate .h file called wrapper that wraps around the functions in the .h file and calls them, but the functions are still not implemented and working. And honestly I highly doubt what I did is correct
Here is my code:
hardware.h - the header file that came with the .lib file (note only putting up one function)
extern "C" int WINAPI GetDigitalOutputInfo(unsigned int deviceNumbers[16],
unsigned int numBits[16],
unsigned int numLines[16]);
_hardware.h - wrapper around the original header file
#pragma once
#include <Windows.h>
#ifdef Hardware_EXPORTS
#define Hardware_API __declspec(dllexport)
#else
#define Hardware_API __declspec(dllimport)
#endif
namespace Hardware
{
class Functions
{
public:
static Hardware_API int NewGetDigitalOutputInfo(unsigned int deviceNumbers[16], unsigned int numBits[16], unsigned int numLines[16]);
};
}
Hardware.cpp - implementing the wrapper
#include "stdafx.h"
#include "hardware.h"
#include "_hardware.h"
#pragma comment(lib, "..\\lib\\PlexDO.lib")
#pragma comment(lib, "legacy_stdio_definitions.lib")
namespace Hardware
{
int Functions::NewGetDigitalOutputInfo(unsigned int deviceNumbers[16], unsigned int numBits[16], unsigned int numLines[16]) {
return GetDigitalOutputInfo(deviceNumbers, numBits, numLines);
}
}
Anyway I feel like making a wrapper is pointless as I should be able to just use the original .h file and .lib file directly to call the functions. Unless making a wrapper is the only way I can make a dll without getting the lib file source code. Are there ways to make a dll without knowing the lib file source code? Is there a way to import the lib file directly into Python? Any help is appreciated.