VS2005 编译环境,解决 Runtime Error(运行时错误): R6034。

问题:Runtime Error R6034
在VS2005编译环境下,用makefile编译的程序爆出了一个可恶的Runtime Error。
错误如下图:

提示信息是:
Runtime Error!
R6034
An application has made an attempt to load the C runtime library incorrectly. Please contact the application’s support team for more information.
无法正常载入 C runtime library。

问题追因
程序生成之后直接执行是没有问题的,而打包后的程序却有问题,看来应该是缺少了什么文件。于是我对编译程序生成的文件一个个删除,并查看检查程序的运行情况。在$(APP).exe.manifest被文件删除之后,R6034现身了,看来罪魁祸首就是它了。
我又在MSDN上搜索R6034,得到了这个Error描述的:

C Run-Time Error R6034
Error Message

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.

这么以来更确认了出现这个问题的原因:缺少了manifest,程序因此无法正常载入C runtime library。

解决办法
解决方法有两个:

  1. 将编译得到的 $(APP).exe.manifest 一并打包,即和应用程序放在同一个文件夹下;
  2. 将manifest文件直接嵌入到可执行文件。

嵌入到可执行文件的方法是,需要在生成exe之后在执行下面的命令:

mt.exe –manifest $(APP).exe.manifest -outputresource:$(APP).exe;1

编译DLL的话,有一点点小区别的。

mt.exe –manifest $(LIB).dll.manifest -outputresource:$(LIB).dll;2

后话
VC2005搞出个这玩意有什么好处?

Posted by 王永杰 in C&C++
8 12月

9条评论 »

  1. free dvd burning software…

    Fall back to GetProcAddress entry in another DLL version….

    引用 作者: free dvd burning software — 06月 4, 2008 @ 5:51

  2. copy vhs to dvd…

    There is no guarantee that the space used by a file generated with filegen will be consecutive. If you want to program with this kind of control, use the Windows Defragmentation API:…

    引用 作者: copy vhs to dvd — 06月 4, 2008 @ 16:33

  3. download dvd decoders…

    Additionally, even in scenarios wher Cable/ DSL is provided by your Internet Service Provider, there can be connection/ configuration issues that slow down your network connection to a crawl. Please run one of the Bandwidth Speed Tests to see how fast …

    引用 作者: download dvd decoders — 06月 4, 2008 @ 19:02

  4. burn with dvd decrypter…

    – WWW Technology Someone\’s Reading Speed Up Sites with php Caching WP- Plugin: AskApache Password Prote Instruct Search Engines to come bac HTTP Packet Capturing to debug Apac Delete extra wordpress files Post- I Redirecting Wordpress Feeds to Feed…

    引用 作者: burn with dvd decrypter — 06月 4, 2008 @ 20:22

  5. dvd shrink…

    You may find this error when you try to register WCF service host using HTTP binding in windows vista. I had the same problem and I found the perfect solution here….

    引用 作者: dvd shrink — 06月 4, 2008 @ 23:08

  6. dvd record vhs…

    (ARA)- Does your computer take forever to load programs or change pages when you’ re surfing the Internet? Have you ever been in the middle of writing an e- mail and it freezes, forcing you to reboot and lose all your work? There are few things more …

    引用 作者: dvd record vhs — 06月 5, 2008 @ 0:28

  7. program pro game rip…

    “ I sat him down and told him what I thought the problems were with security and force protection and turned him loose,” said Sergeant Fenner. “ Within three months, he’ d established new entry control procedures, with Staff Sgt. David Dike, al…

    引用 作者: program pro game rip — 06月 5, 2008 @ 1:57

  8. game coping software…

    More Photos/ Subscribe Via Email Subscribe To ORKUT An Epitome: Linux Rocks by Email/ Special Days An error has occurred; the feed is probably down. Try again later. / Page Content About About Orkut Fedora 8: Guide Orkut Security Orkut Tips & Tricks Pc…

    引用 作者: game coping software — 06月 7, 2008 @ 3:00

  9. It would be interesting to know details

    评论 作者: Lucien — 11月 6, 2008 @ 14:01

发表评论