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工程下项目--->属性--->清单工具---->命令行有相关的命令参数。在命令中添加这一个命令之后重新执行,问题就可解决了。

C Run-Time Error R6034问题的解决的更多相关文章

  1. LR 报错误: C interpreter run time error: Error -- Unresolved symbol : vuser_end解决方法

    Action.c(33): Error: C interpreter run time error: Action.c (33):  Error -- Unresolved symbol : vuse ...

  2. ArcGIS10.4 Runtime Error R6034

    现在甲方采购的ArcGIS Desktop正版,一般都是较高的版本(10.4或10.4.1),但10.4经常报出C++ Runtime R6034错误. 问题 "Microsoft Visu ...

  3. Runtime Error R6034 Application has attempt to load the C runtime library incorrectly

    1.问题描述 vs2015 去开发一个写入pg数据库的程序,使用libpqxx.dll,libpq.dll,这个库文件之前是用vs2008的程序中复制过来的,基于的运行时库应该是vs2008,现在开发 ...

  4. 运行bee run之后出现的错误以及解决方法Failed to build the application:

      运行bee run之后出现的错误以及解决方法 创建一个beego项目 bee new myapp 在该项目执行下面的代码 bee run 出现的问题 2020/04/22 21:12:07 INF ...

  5. vss error reading from file 解决方法

    vss error reading from file 解决方法 1 若服务器中存在 vss/data/backup目录,请将该目录删掉2 运行cmd cd.. cd C:\Program Files ...

  6. Error reading from file 解决办法

    最近安装程序遇见这个问题: Error reading from file. 解决办法: 给这个程序添加权限: 添加SYSTEM的读写改..如果比较懒,直接全部允许. 然后Retry.

  7. 安装CAD出现Error 1904.Module的解决方法

    在安装AutoCAD2008时,安装过程中出现了一个小错误,虽然说不影响使用,也不影响功能,但还是需要把这个问题解决,今天就和大家分享解决这个问题的方法. 错误描述 会在安装过程中出现错误提示:Err ...

  8. Last Defence (run time error)

    Last Defence时间限制:1000 ms | 内存限制:65535 KB描述Given two integers A and B. Sequence S is defined as follo ...

  9. Android studio Error: Modules no specified解决和真机调试

    如何配置SDK百度一大堆: 前言:Android Studio很完善,如果SDK配置好,理论上就是 创建项目->创建个APP(名字自己随便起)->打开手机开发者模式运行即可:如果出了问题, ...

随机推荐

  1. 改用Struts2.5 出现404 错误

    这个是因为现在Struts 使用  2.5   只需要8 个 jar 包 Xworks-core 已经加到 struts-core中了 原因 是  Jar 包 冲突  导致 的    其次 如果 使用 ...

  2. appium 原理解析

    Appium是 c/s模式的appium是基于 webdriver 协议添加对移动设备自化api扩展而成的webdriver 是基于 http协议的,第一连接会建立个 session 会话,并通过 p ...

  3. python和C语言混编的几种方式

    Python这些年风头一直很盛,占据了很多领域的位置,Web.大数据.人工智能.运维均有它的身影,甚至图形界面做的也很顺,乃至full-stack这个词语刚出来的时候,似乎就是为了描述它. Pytho ...

  4. css3换行的三方式的对比(整理)

    CSS3 文本换行 (转载..) 作者 张歆琳 关注 2016.06.20 10:49* 字数 1101 阅读 676评论 1喜欢 6 文本换行其实是个非常常用但并不起眼的特性.你什么都不用设,浏览器 ...

  5. D. How many trees? DP

    D. How many trees? time limit per test 1 second memory limit per test 64 megabytes input standard in ...

  6. Mysql主从复制原理及配置

    Mysql主从复制原理及配置 1.复制概述 Mysql内建的复制功能是构建大型,高性能应用程序的基础.将Mysql的数据分布到多个系统上去,这种分布的机制,是通过将Mysql的某一台主机的数据复制到其 ...

  7. Ubuntu 定时任务中的环境变量设置

    背景 1,定时任务命令 crontab -e 2,默认的环境变量 SHELL=/bin/sh PATH=/usr/bin:/bin PWD=/home/owl LANG=zh_CN.UTF- SHLV ...

  8. HDU1257 最少拦截系统 (贪心+STL+二分)

    第一次在博客园写博客,好紧张 .博客搬家居然很多代码成了乱码,欲哭无泪,妈咪. 开学东西太多了吧,没时间写备注,有点时候只能贴个代码,以后有时间再加备注吧,只贴代码不是好习惯. 咦,贪心怎么写,我只会 ...

  9. django中间件Middleware

    熟悉web开发的同学对hook钩子肯定不陌生,通过钩子可以方便的实现一些触发和回调,并且做一些过滤和拦截. django中的中间件(middleware)就是类似钩子的一种存在.下面我们来介绍一下,并 ...

  10. thinking in java 随笔

    初始化顺序 在一个类里,初始化的顺序是由变量在类内的定义顺序决定的.即使变量定义大量遍布于方法定义的中间,那些变量仍会在调用任何方法之前得到初始化--甚至在构建器调用之前.例如: class Tag ...