gpt4 book ai didi

c++ - 如何在 C/C++ 中链接两个 .so

转载 作者:行者123 更新时间:2023-11-30 21:10:48 25 4
gpt4 key购买 nike

我想将两个 .so 相互链接。 场景是: 1) .so 中定义了具有相同名称的方法(例如 void fun() ) 2)假设我们从第一个.so调用这个方法,那么调用应该转到第二个.so中定义的方法

这怎么可能?

// Module 2

#include <stdio.h>
void fun();

void fun()
{
printf(""from 2nd .so\n"");
}


// Module 1

#include <stdio.h>
void fun();

void fun()
{
printf("from 1st .so\n");
}

int main()
{
fun();
return 0;
}

最佳答案

如果你真的想要这个,我想你可以处理这个延迟加载库。

下面是 unix 中的一个示例: Delay-Load equivalent in unix based systems

关于c++ - 如何在 C/C++ 中链接两个 .so,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27564545/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com