0

ばかげた質問をする前に、あらかじめお詫び申し上げます
が、自分の能力でウェブを検索しましたが、私の場合に役立つ答えは見つかりませんでした。
私の質問は:コードが makefileによって生成され た makefile から MS Visual Studio 2008 でコンパイルされたときに、 *.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 がマニフェストを必要としないような方法で、ベイクファイルを作成することはできますか?

    これを解決するために追加したいコンパイラ/リンカーフラグをいくつか意味しますが、このフラグはわかりません。

あなたの助けを心待ちにしています。

4

1 に答える 1

0

これを解決する方法を見つけました。Bakefile にはすでに xml-tag という名前があります

<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;
}

ベイクファイルは (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>

バッチは (genbake.bat):

bakefile -f msvc plain_exe.bkl -o Makefile.mak
call C:\PROGRA~1\MICROS~1.0\VC\vcvarsall.bat
nmake -f Makefile.mak
cmd

バッチをトリガーしてすべてをビルドします。

于 2013-07-20T06:45:59.550 に答える