On Windows, mkbundle fails with linker error

后端 未结 2 1677
逝去的感伤
逝去的感伤 2021-01-14 01:17

I am trying to build a console utility that needs to be run in environments that may not have .NET installed. Mono\'s mkbundle seems to be a great solution for this problem,

2条回答
  •  甜味超标
    2021-01-14 02:01

    after last post from me. I tried a lot of ways.

    finally , i found how to resolve this issue.

    you must use mkbundle like this:

    mkbundle --deps mkbundleTest.exe -o test.exe --keeptemp

    the point is the --keeptemp param.

    with this param ,mkbundle will save the temp.c file on your current directory.

    then copy out this line :

    cl.exe /MT /I "C:\Program Files (x86)\Windows Kits\8.1\Include\um" /I "C:\Program Files (x86)\Windows Kits\8.1\Include\shared" /I "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include" /I "C:\Program Files (x86)\Mono\include\mono-2.0" /I "." "temp.c" "temp.o" "C:\Program Files (x86)\Mono\lib\monosgen-2.0.lib" /link /NODEFAULTLIB /SUBSYSTEM:windows /ENTRY:mainCRTStartup kernel32.lib version.lib Ws2_32.lib Mswsock.lib Psapi.lib shell32.lib OleAut32.lib ole32.lib winmm.lib user32.lib libvcruntime.lib advapi32.lib OLDNAMES.lib libucrt.lib /out:test.exe

    remove two params from this line: /NODEFAULTLIB /SUBSYSTEM:windows ,

    the final command line like this:

    cl.exe /MT /I "C:\Program Files (x86)\Windows Kits\8.1\Include\um" /I "C:\Program Files (x86)\Windows Kits\8.1\Include\shared" /I "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include" /I "C:\Program Files (x86)\Mono\include\mono-2.0" /I "." "temp.c" "temp.o" "C:\Program Files (x86)\Mono\lib\monosgen-2.0.lib" /link /ENTRY:mainCRTStartup kernel32.lib version.lib Ws2_32.lib Mswsock.lib Psapi.lib shell32.lib OleAut32.lib ole32.lib winmm.lib user32.lib libvcruntime.lib advapi32.lib OLDNAMES.lib libucrt.lib /out:test.exe

    then you will get your bundled application.

    and this way working for me.

提交回复
热议问题