我想将参数传递到 C++ 共享库 lib.so 形式的 loader.exe 中。
抱歉,请更新问题。
共享库如:
int count(){
int num = 9;
int result = 0;
for ( int i = 0; i < num; i++ ){
result ++;
}
return result;
}
在loader.exe中,使用dlopen来加载它。
void *handler = dlopen("lib.so", RTLD_LAZY);
我想更改 loader.exe 中 num 的值。当我调用函数 count() 时,它可以给我新的结果。
我该怎么办?
谢谢!
最佳答案
您可以在加载程序中定义一个全局变量num
(设置为所需的值)并进行更改
int num = 9;
至
extern int num;
.
关于c++ - 将参数传递到 C++ 共享库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17344286/