博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C Run-Time Error R6034问题的解决
阅读量:4509 次
发布时间:2019-06-08

本文共 2294 字,大约阅读时间需要 7 分钟。

1、问题描述

      这两天一直在用vs2008编写一个小项目,需要在c++代码中通过命令行的方式调用cl.exe和link.exe,也就是给编译器cl和链接器link传递参数,然后编译链接生成可执行文件exe.最终生成的result.exe运行时老出现Runtime Error R6034 An application has made an attempt to load the C runtime library incorrectly.的错误,围绕这个问题,我查了两天的资料,最后终于解决了。。

  在此简单的记录一下解决方法,方便以后用到。

2、问题解决

  在利用命令行的方式编译链接生成可执行文件之前,可以将需要传递给cl.exe的源程序(.cpp,.h)文件拎出来,利用这些源文件手动的创建一个vs2008工程,然后编译链接这个vs2008工程生成可执行文件。做这一步是为了保证生成的可执行文件是你本人需要的结果,如果这个手动工程都不能生成你需要的exe,那通过命令行的方式生成的exe肯定就不是你想要得到的结果。

  生成好vs2008工程并且执行正确后,在这个工程的项目--->属性-->c/c++--->命令行,你会看到一大堆的命令,其实这就是传递给cl.exe的命令,同样的道理,在项目--->属性-->链接器--->命令行中可以看到传递给link.exe的命令。

  按照上面所说的方法,我在自己的项目中编写好自动生成exe 的代码生成一个exe。然后点击这个exe,就出现Runtime Error R6034 。

  下面贴上解决该问题的原文:

  An application has made an attempt to load the C runtime library without using a manifest. This is an unsupported way to load Visual C++ DLLs. You need to modify your application to build with a manifest. For more information, see the "Visual C++ Libraries as Shared Side-by-Side Assemblies" topic in the product documentation.

  Applications must use a manifest to load the C runtime library. For more information, see Visual C++ Libraries as Shared Side-by-Side Assemblies and Manifest Generation in Visual Studio.
In release builds, the diagnostic message reads: "An application has made an attempt to load the C runtime library incorrectly. Please contact the application's support team for more information."
  To correct this error
  Rebuild your application to include a manifest. Building an application with Visual Studio automatically puts the manifest into the resulting .exe or .dll file. If you are building at the command line, use the mt.exe tool to add the manifest as a resource. Use resource ID 1 if you build an .exe, and resource ID 2 if you build a .dll. For more information, see How to: Embed a Manifest Inside a C/C++ Application.

  重点是这一句:If you are building at the command line, use the mt.exe tool to add the manifest as a resource. Use resource ID 1 if you build an .exe, and resource ID 2 if you build a .dll. For more information, see How to: Embed a Manifest Inside a C/C++ Application.

  按照这个说法,命令行不仅需要调用cl.exe和link.exe,还需要调用一个叫mt.exe的,mt.exe的参数其实在上文创建的vs2008工程下项目--->属性--->清单工具---->命令行有相关的命令参数。在命令中添加这一个命令之后重新执行,问题就可解决了。

转载于:https://www.cnblogs.com/LCCRNblog/p/4547892.html

你可能感兴趣的文章
将VS2013项目转成VS2010项目的方法
查看>>
[置顶] 怎么对待重复的代码
查看>>
多种方法实现H5网页图片动画效果;
查看>>
Ubuntu/CentOS下使用脚本自动安装 Docker
查看>>
源码解读Mybatis List列表In查询实现的注意事项
查看>>
POJ 2311 Cutting Game(二维SG+Multi-Nim)
查看>>
1978 Fibonacci数列 3
查看>>
1225 八数码难题
查看>>
C#控件的闪烁问题解决方法总结
查看>>
js 冒泡事件与解决冒泡事件
查看>>
2018-2019赛季多校联合新生训练赛第七场(2018/12/16)补题题解
查看>>
后台全选功能以及数据的提交方法
查看>>
Android 动画效果 及 自定义动画
查看>>
const与#define相比有什么不同?
查看>>
Eclipse4.7 SpringIDE插件的安装
查看>>
C#面向对象基础
查看>>
Jquery页面加载效果
查看>>
ios对new Date() 的兼容问题
查看>>
Spark发展现状与战线
查看>>
Charles常用设置
查看>>