使用存根自动解决缺少库中未定义的引用?
我正在为一个为 MSVC 开发的 C/(C++) 项目构建一些单元测试内容。我需要将其移植到 g++ / MinGw。有一个用 VS 构建的库(DLL)。我无法让这个库与其余代码链接,我总是收到未定义的引用错误。 MSVC 和 g++ 之间的名称管理似乎不兼容。不幸的是,我无法使用 g++ 重新编译该库,因为它使用了一些与 g++ (MFC/AFX) 不兼容的 Microsoft 东西。
所以我想知道是否有任何方法告诉 g++ 将所有未定义的引用替换为仅返回 0 或 Null 的简单存根函数。
因为我实际上并不需要任何函数,而且我什至不会调用调用任何缺失函数的函数。我只是想在那里有一些东西,以便项目可以在不更改我想要测试的代码的情况下进行编译。
有什么办法可以做到这一点吗?是否有一个工具可以提取所有公开的函数并创建一个仅包含存根函数的替换库?
I am building some unit testing stuff for a C/(C++) project that was developed for MSVC. I need to port it to g++ / MinGw. There is a library (DLL) that was build with VS. I can not get this library to link with the rest of the code, i always get undefined reference errors. It seems that the name mangeling between MSVC and g++ not compatible. Unfortunately I can not recompile the library with g++ because it uses some Microsoft Stuff that is incompatible with g++ (MFC/AFX).
So I wonder if there is any way to tell g++ to replace all undefined references with simple stub functions that just return 0 or Null.
Because I dont really need any of the functions, and I won't even call functions that call any of the missing functions. I just want to have something there so that the project compiles without changing the code that i want to test.
Is there any way to do that? Is there a tool that maybe extracts all the exposed functions and creates a replacement lib that only contains the stub functions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论