Answer the question
In order to leave comments, you need to log in
Using rust from cpp?
There is a dll on rust.
How to use function from it in cpp?
lib.rs
pub extern fn lt() {
println!("Hello from the library!");
}
#include <windows.h>
#include <iostream>
using namespace std;
typedef void (__stdcall *f_lt)();
int main()
{
HINSTANCE hGetProcIDDLL = LoadLibrary("C:\\Users\\acer\\desktop\\c\\rlib.dll");
if (!hGetProcIDDLL) {
std::cout << "could not load the dynamic library" << std::endl;
return 1;
}else{
std::cout << "success load the dynamic library" << std::endl;
f_lt lt = (f_lt)GetProcAddress(hGetProcIDDLL, "lt");
lt();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question