我怎么能摆脱*.exe.从MSVC编译的exe文件中获取manifest文件
Ho can I get rid of *.exe.manifest files form the MSVC compiled exe files?
在问一些愚蠢的问题之前我先道歉,
但是我在网上搜索了我的能力,但没有找到任何适合我的答案。
我的问题是:
我怎样才能摆脱尴尬的*.exe。manifest与相关联*.exe,
当代码编译与MS Visual Studio 2008从一个bakefile生成makefile?
首先我创建了一个bakefile,如下所示:
然后我创建了一个批处理文件:<?xml version="1.0" ?> <!-- =========================================== Plain EXE =========================================== --> <makefile> <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> <!-- HERE OUR PROJECT GOES --> <exe id="MyApplication"> <app-type> console </app-type> <!-- Compiler Specific --> <cflags>/TC /W4 /Za </cflags> <!-- Compile code as C. /TP , as C++ /Tc <source file> means this file is C only, /Tp means this file is C++ only. /O1 minimize space, /O2 maximize speed, /Os favor code space, /Ot favor code speed. /Wall enable all warnings (gives warning on own headers like stdio.h). /Wp64 enable 64 bit porting warnings (will be deprecated in future). /Za disable extensions, can be used with plain console apps but not with gui apps. --> <!-- <define>SOMEMACRO</define> --> <!-- <define>_OPENGLUT_STATIC</define> --> <!-- use underscore '_' before macro --> <!-- <include>../include/foo</include> --> <!-- <include>C:xtralibsappu</include> --> <!-- <include>C:xtralibsOpenGLUT-0.6.3vc</include> --> <!-- <headers>utils.h additionalheader.h</headers> --> <sys-lib> user32.lib kernel32.lib shell32.lib gdi32.lib comctl32.lib ole32.lib winmm </sys-lib> <!-- OpenGLUT_static.lib OpenGLUT.lib glu32.lib opengl32.lib --> <!-- <sys-lib>png</sys-lib> --> <!-- <sys-lib>OpenGLUT</sys-lib> --> <!-- <sys-lib>z</sys-lib> --> <!-- <lib-path>/usr/lib/mysql</lib-path> --> <!-- <lib-path>C:xtralibsOpenGLUT-0.6.3vc</lib-path> --> <!-- note that hardcoding library paths like this is a bad idea, it's done here only for the sake of simplicity; in real bakefile, an <option> would be used --> <!--<library>mylib</library> --> <ldflags> /ENTRY:"mainCRTStartup"</ldflags> <!-- required for gui apps only, >can be used with console apps also --> <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> <!-- ~~~~~~~~ Compiler Specific definition Ends ~~~~~~~~~~ --> <!-- COMMON --> <!-- <win32-res> resource.rc </win32-res> --> <sources> test.c </sources> </exe> <!-- HERE OUR PROJECT ENDS --> <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> </makefile>
bakefile - fmsvc -o Makefile。mak testing.bkl
call "%programfiles%Microsoft Visual Studio 9.0VC vcvarsmall .bat"
nmake -f makefile . makk
cmd
之后一个Makefile被创建为:
# ========================================================================= # This makefile was generated by # Bakefile 0.2.9 (http://www.bakefile.org) # Do not modify, all changes will be overwritten! # ========================================================================= # ------------------------------------------------------------------------- # These are configurable options: # ------------------------------------------------------------------------- # C compiler CC = cl # Standard flags for CC CFLAGS = # Standard preprocessor flags (common for CC and CXX) CPPFLAGS = # Standard linker flags LDFLAGS = # ------------------------------------------------------------------------- # Do not modify the rest of this file! # ------------------------------------------------------------------------- ### Variables: ### MYAPPLICATION_CFLAGS = /MD /DWIN32 /D_CONSOLE /TC /W4 /Za $(CPPFLAGS) $(CFLAGS) MYAPPLICATION_OBJECTS = MyApplication_test.obj ### Conditionally set variables: ### ### Targets: ### all: MyApplication.exe clean: -if exist .*.obj del .*.obj -if exist .*.res del .*.res -if exist .*.pch del .*.pch -if exist MyApplication.exe del MyApplication.exe -if exist MyApplication.ilk del MyApplication.ilk -if exist MyApplication.pdb del MyApplication.pdb MyApplication.exe: $(MYAPPLICATION_OBJECTS) link /NOLOGO /OUT:$@ /SUBSYSTEM:CONSOLE /ENTRY:"mainCRTStartup" $(LDFLAGS) @<< $(MYAPPLICATION_OBJECTS) user32.lib kernel32.lib shell32.lib gdi32.lib comctl32.lib ole32.lib winmm.lib << MyApplication_test.obj: .test.c $(CC) /c /nologo /TC /Fo$@ $(MYAPPLICATION_CFLAGS) .test.c
最后用Visual Studio 2008编译了我的代码。在此之前,一切都很好。
现在主要问题来了。
Visual Studio创建一个清单文件,它实际上是一个纯xml文件。
当我删除清单时,我的exe不运行
- 我能设法以这样一种方式创建bakefile,以便编译的exe永远不需要清单?
我的意思是我想添加一些编译器/链接器标志来解决这个问题,但我不知道这个标志。
我找到了解决这个问题的方法。Bakefile已经有了一个名为
的xml标签<postlink-command></postlink-command>
我们可以运行mt.exe来嵌入清单,最后删除清单。
C代码是:/* main.c */
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
printf("Hello world!n");
system ("PAUSE");
return 0;
}
bakefile是(plain_exe.bkl):
<?xml version="1.0" ?>
<!--
===========================================
A SIMPLE EXE
===========================================
-->
<makefile>
<exe id="hello">
<sources> main.c </sources>
<sys-lib> user32.lib kernel32.lib shell32 </sys-lib>
<pic>on</pic>
<postlink-command> mt.exe -manifest $(id).exe.manifest -outputresource:$(id).exe;1
<postlink-command> del $(id).exe.manifest </postlink-command>
</exe>
</makefile>
批处理是(genbaker .bat):
bakefile -f msvc plain_exe.bkl -o Makefile.mak
call C:PROGRA~1MICROS~1.0VCvcvarsall.bat
nmake -f Makefile.mak
cmd
相关文章:
- 终端不会为C++文件创建.exe文件吗
- 从 exe 文件 (Visual Studio ) 启动时调试断言失败
- 1d.exe找不到SFML文件?
- VI工作室代码错误无法打开输出文件主.exe
- 如何在Visual Studio Code中重命名我的a.exe文件?
- 在VS Code中编译C / C ++时如何禁用自动创建EXE文件?
- 如何从Windows控制台调用.exe(C++)以在不同的目录(或任何目录)中创建文件夹?
- 来自Visual Studio中控制台项目的exe文件?
- 在安卓应用程序中使用.exe文件
- 我应该如何获取配置文件的绝对路径与 Windows .exe一起发布?
- VS:在构建/exe中包含资源文件
- gcc 找不到 -lgcc, g++.exe: 错误: 创建进程: 没有这样的文件或目录
- 无法在代码块 IDE 中打开输出文件.exe
- 从Visual Studio项目到文件.exe(Qt)
- Mac - 创建文件.exe
- 通过php(LINUX)运行Qt生成的可执行文件(EXE)
- 找不到文件.exe
- 无法打开文件.exe 1104
- 一个文件可以同时是可执行文件(EXE)和动态链接库(DLL)吗?
- 将.cpp文件编译为程序内的EXE文件(EXE文件)