混合code。与/ MT和/ MD编译 [英] mixing code compiled with /MT and /MD

查看:294
本文介绍了混合code。与/ MT和/ MD编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个庞大的身躯code,用/ MT(即期待静态针对CRT链接)编译。我需要这样一个静态的第三方库,该库已建成/ MD(即预计到CRT动态链接)结合起来。

I have a large body of code, compiled with /MT (i.e. expecting to statically link against the CRT). I need to combine this with a static third-party library, which has been built with /MD (i.e. expecting to link the CRT dynamically).

时的理论上能够使两个连接成一个可执行无需重新编译要么?

Is it theoretically possible to link the two into one executable without recompiling either?

如果我用/ NODEFAULTLIB链接:MSVCRT,我结束了少数喜欢的东西 __ imp__wgetenv 未定义的引用。我很想尝试在自己的code实现这些功能,转发到 wgetenv 等,那是值得尝试的,否则我会直接运行到下一个问题?

If I link with /nodefaultlib:msvcrt, I end up with a small number of undefined references to things like __imp__wgetenv. I'm tempted to try implementing those functions in my own code, forwarding to wgetenv, etc. Is that worth trying, or will I run straight into the next problem?

不幸的是,我采取装箱第三方code到一个单独的DLL的容易的选择禁止: - /

Unfortunately I'm Forbidden from taking the easy option of packing the thirdparty code into a separate DLL :-/

推荐答案

没有。 / MT和/ MD是相互排斥的。

No. /MT and /MD are mutually exclusive.

传递给连接器的给定调用的所有模块必须已编译相同的运行时库编译器选项( / MD / MT / LD )。

All modules passed to a given invocation of the linker must have been compiled with the same run-time library compiler option (/MD, /MT, /LD).

来源

这篇关于混合code。与/ MT和/ MD编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆