force visual studio将lib文件中的所有符号链接起来

编程入门 行业动态 更新时间:2024-10-23 01:43:48
本文介绍了force visual studio将lib文件中的所有符号链接起来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有任何方法强制Visual Studio将所有符号从一个lib文件链接到dll as atm它是优化未使用的函数,这是程序使用dll在运行时需要的。

我尝试使用/ OPT:NOREF和/ OPT:NOICF,但它们似乎不起作用。

我需要他们的原因是因为他们是全局类,注册他们自己的控制器,他们没有链接在DLL。

解决方案

我不知道Visual Studio中有没有更优雅的方式,但我们使用它的跨平台解决方案有两个宏强制要求链接problamatic对象文件。

一个放在要排除的函数的源文件中,另一个放在函数中

类似于

# define force_select(__)(x)int force_link _ ## x = 0; #define FORCE_LINK_THAT(x){extern int force_link _ ## x; force_link _ ## x = 1; }

这不是很优雅,但我们没有找到一个更好的解决方案, / p>

Is there any way to force visual studio to link all symbols from a lib file into the dll as atm it is optimizing "unused" functions which are needed by the program using the dll at run time.

I tried using the /OPT:NOREF and /OPT:NOICF but they dont seem to work.

The reason i need them is because they are global class which register them selves with a controller and they are not being linked in the dll.

解决方案

I don't know if there's a more elegant way in Visual Studio, but the cross-platform solution we use it to have two macros that force the problamatic object file to be linked.

One is placed in the source file of functions that are being excluded, the other is placed in a function that the linker knows will be called.

Something like;

#define FORCE_LINK_THIS(x) int force_link_##x = 0; #define FORCE_LINK_THAT(x) { extern int force_link_##x; force_link_##x = 1; }

It's not exactly elegant, but we haven't found a better solution that works across platforms.

更多推荐

force visual studio将lib文件中的所有符号链接起来

本文发布于:2023-10-31 07:38:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545457.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:符号   链接   文件   visual   force

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!