在问一些愚蠢的问题之前,我事先请求道歉,
但我以我的能力搜索了网络,但没有找到任何适合我的答案。
我的问题是:
当使用 MS Visual Studio 2008 从bakefile生成的 makefile编译代码时,
如何摆脱与*.exe相关的令人尴尬的* .exe.manifest ?
首先,我创建了一个烘焙文件,如下所示:
<?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:\xtralibs\appu</include> --> <!-- <include>C:\xtralibs\OpenGLUT-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:\xtralibs\OpenGLUT-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 -f msvc -o Makefile.mak testing.bkl
调用“%programfiles%\Microsoft Visual Studio 9.0\VC\vcvarsall.bat”
nmake -f Makefile.mak
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 没有运行。
- 我可以设法以这样的方式创建烘焙文件,以便编译的 exe 永远不需要清单吗?
我的意思是我想添加一些编译器/链接器标志来解决这个问题,但我不知道这个标志。
我热切地等待你的帮助。