将消息编译器 (mc.exe) 配置为 VC++ 2010 中的自定义编译器步骤? [英] Configure the message compiler (mc.exe) as a custom compiler step in VC++ 2010?

查看:42
本文介绍了将消息编译器 (mc.exe) 配置为 VC++ 2010 中的自定义编译器步骤?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能列出配置 mc.exe(消息编译器)以将 .mc 文件编译为 .rc 文件作为 VC++ 2010 中的自定义编译器步骤的具体和详细步骤吗?
我真的不知道该怎么做.

Can anyone list the specific and detailed steps to configure mc.exe (the message compiler) to compile a .mc file into a .rc file as a custom compiler step in VC++ 2010?
I am really lost on how to do this.

推荐答案

Hans Passant 几乎是对的.不幸的是,$(InputPath) 和 $(InputName) 没有在 VS 2010 中定义.相反,创建您的消息文件:

Hans Passant almost had it right. Unfortunately, $(InputPath) and $(InputName) aren't defined in VS 2010. Instead, create your message file:

  • 右键单击您的项目->添加->新项目
  • 选择文本文件 (.txt),但将其命名为.mc"文件(如messages.mc")
  • 创建一个资源文件(比如resources.rc")
  • 编辑资源文件,使其只包含一行:

#include "messages.rc"

#include "messages.rc"

该文件将由消息编译器生成.现在添加一个自定义构建步骤来运行消息编译器:

That file will be generated by the message compiler. Now add a custom build step to run the message compiler:

  • 右键单击 messages.mc 并选择属性.
  • 在属性"对话框中,将配置"设置为所有配置".
  • 在配置属性"下点击常规".
  • 确保从构建中排除"属性设置为否".
  • 从下拉菜单中将项目类型"属性设置为自定义构建工具",然后单击应用"按钮,这样就会出现自定义构建工具"属性.
  • 点击自定义构建工具"属性下的常规".
  • 将命令行"属性设置为:

  • Right-click on messages.mc and select Properties.
  • In the Properties dialog set Configuration to "All Configurations".
  • Under "Configuration Properties" click on "General".
  • Ensure the "Excluded From Build" property is set to "No".
  • Set the "Item Type" property to "Custom Build Tool" from the drop-down menu and click the "Apply" button so the "Custom Build Tool" property will appear.
  • Click on "General" under the "Custom Build Tool" property.
  • Set the "Command Line" property to:

mc %(全路径)

  • 将描述属性设置为类似编译消息..."

  • Set the Description property to something like "Compiling Messages..."

    %(文件名).rc;%(文件名).h;MSG0409.bin

  • %(Filename).rc;%(Filename).h;MSG0409.bin

    文件 MSG00409.bin 来自 messages.mc 中的以下行:

    The file MSG00409.bin is from having the following line in messages.mc:

    语言名称 = (English=0x409:MSG00409)

    LanguageNames = (English=0x409:MSG00409)

    您添加到messages.mc 的每种语言都可以有一个bin 文件.在输出中列出它们的好处是,当项目被清理时,它们将被删除.

    There can be a bin file for each language you add to messages.mc. The nice part of listing them in the output is that it will be deleted when the project is cleaned.

    我唯一不确定的是设置Execute Before"属性以保证在编译 resource.rc 之前生成 messages.rc.我不必设置它,但是如果您发现资源编译器试图在消息编译器之前执行,那么您必须设置此属性.对于messages.mc"文件,它被禁用,但可以在项目的自定义构建步骤"属性中设置.

    The only thing I'm not sure about is setting the "Execute Before" property to guarantee messages.rc is generated before resource.rc is compiled. I didn't have to set it, but if you find the resource compiler is trying to execute before the message compiler, then you'll have to set this property. It's disabled for the "messages.mc" file, but it can be set in the project's "Custom Build Step" property.

    这篇关于将消息编译器 (mc.exe) 配置为 VC++ 2010 中的自定义编译器步骤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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