问题描述
我正在尝试构建一个控制台实用程序,该实用程序需要在可能未安装 .NET 的环境中运行.Mono 的 mkbundle 似乎是解决这个问题的一个很好的解决方案,但是当在一个简单的项目上通过 cygwin 在 Windows 10 上运行 mkbundle (Mono 4.6.1.3) 时,这是我收到的输出:
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, but when running mkbundle (Mono 4.6.1.3) on Windows 10 via cygwin on a trivial project, this is the output I receive:
$ mkbundle --deps mkbundleTest.exe -o test.exe
OS is: Windows
Sources: 1 Auto-dependencies: True
embedding: C:UsersJasonDocumentsmkbundleTestmkbundleTestinDebugmkbundleTest.exe
config from: C:UsersJasonDocumentsmkbundleTestmkbundleTestinDebugmkbundleTest.exe.config
embedding: C:Program FilesMonolibmono4.5mscorlib.dll
AS = as (default)
as -o temp.o temp.s
Compiling:
CC = cl.exe (default)
WINSDK = C:Program Files (x86)Windows Kits8.1 (default)
VSINCLUDE = C:Program Files (x86)Microsoft Visual Studio 14.0VC (default)
MONOPREFIX = C:Program Files (x86)Mono (default)
WARNING: Dynamically linking the Mono runtime on Windows is not a tested option.
cl.exe /MT /I "C:Program Files (x86)Windows Kits8.1Includeum" /I "C:Program Files (x86)Windows Kits8.1Includeshared" /I "C:Program Files (x86)Microsoft Visual Studio 14.0VCinclude" /I "C:Program Files (x86)Monoincludemono-2.0" /I "." "temp.c" "temp.o" "C:Program Files (x86)Monolibmonosgen-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
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
cl : Command line warning D9024 : unrecognized source file type 'temp.o', object file assumed
temp.c
Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation. All rights reserved.
/out:temp.exe
/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
temp.obj
temp.o
"C:Program Files (x86)Monolibmonosgen-2.0.lib"
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
libvcruntime.lib(wcschr.obj) : error LNK2001: unresolved external symbol ___isa_available
libvcruntime.lib(memcpy.obj) : error LNK2001: unresolved external symbol ___isa_available
libvcruntime.lib(strchr.obj) : error LNK2001: unresolved external symbol ___isa_available
libucrt.lib(strnlen.obj) : error LNK2001: unresolved external symbol ___isa_available
libvcruntime.lib(memset.obj) : error LNK2001: unresolved external symbol ___isa_available
libvcruntime.lib(memcpy.obj) : error LNK2019: unresolved external symbol ___isa_enabled referenced in function _memcpy
libvcruntime.lib(memset.obj) : error LNK2001: unresolved external symbol ___isa_enabled
libvcruntime.lib(memcpy.obj) : error LNK2019: unresolved external symbol ___favor referenced in function _memcpy
libvcruntime.lib(memset.obj) : error LNK2001: unresolved external symbol ___favor
libucrt.lib(signal.obj) : error LNK2001: unresolved external symbol __SEH_epilog4
libucrt.lib(onexit.obj) : error LNK2001: unresolved external symbol __SEH_epilog4
libucrt.lib(winapi_thunks.obj) : error LNK2001: unresolved external symbol __SEH_epilog4
libucrt.lib(mbctype.obj) : error LNK2001: unresolved external symbol __SEH_epilog4
libucrt.lib(locale_refcounting.obj) : error LNK2001: unresolved external symbol __SEH_epilog4
libucrt.lib(exit.obj) : error LNK2001: unresolved external symbol __SEH_epilog4
libucrt.lib(getenv.obj) : error LNK2001: unresolved external symbol __SEH_epilog4
libucrt.lib(new_handler.obj) : error LNK2001: unresolved external symbol __SEH_epilog4
libucrt.lib(per_thread_data.obj) : error LNK2001: unresolved external symbol __SEH_epilog4
libucrt.lib(wsetlocale.obj) : error LNK2001: unresolved external symbol __SEH_epilog4
libucrt.lib(signal.obj) : error LNK2001: unresolved external symbol __SEH_prolog4
libucrt.lib(onexit.obj) : error LNK2001: unresolved external symbol __SEH_prolog4
libucrt.lib(winapi_thunks.obj) : error LNK2001: unresolved external symbol __SEH_prolog4
libucrt.lib(mbctype.obj) : error LNK2001: unresolved external symbol __SEH_prolog4
libucrt.lib(locale_refcounting.obj) : error LNK2001: unresolved external symbol __SEH_prolog4
libucrt.lib(exit.obj) : error LNK2001: unresolved external symbol __SEH_prolog4
libucrt.lib(getenv.obj) : error LNK2001: unresolved external symbol __SEH_prolog4
libucrt.lib(new_handler.obj) : error LNK2001: unresolved external symbol __SEH_prolog4
libucrt.lib(per_thread_data.obj) : error LNK2001: unresolved external symbol __SEH_prolog4
libucrt.lib(wsetlocale.obj) : error LNK2001: unresolved external symbol __SEH_prolog4
libucrt.lib(invalid_parameter.obj) : error LNK2019: unresolved external symbol __crt_debugger_hook referenced in function ___acrt_call_reportfault
libvcruntime.lib(_exsup4_.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libvcruntime.lib(_exsup_.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(isctype.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(initterm.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(onexit.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libvcruntime.lib(_chandler4_.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(getqloc_downlevel.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(lcmapstringa.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(exit.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(getlocaleinfoa.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(exception_filter.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(initctype.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(getstringtypea.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(get_qualified_locale.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(comparestringa.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(winapi_thunks.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(free_base.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(mbctype.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(invalid_parameter.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(environment_initialization.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(new_handler.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(wsetlocale.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
libucrt.lib(onexit.obj) : error LNK2001: unresolved external symbol ___security_cookie
libvcruntime.lib(_chandler4_.obj) : error LNK2001: unresolved external symbol ___security_cookie
libvcruntime.lib(_exsup4_.obj) : error LNK2001: unresolved external symbol ___security_cookie
libvcruntime.lib(_exsup_.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(getlocaleinfoa.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(isctype.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(initterm.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(onexit.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(lcmapstringa.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(exit.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(exit.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(signal.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(initctype.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(getstringtypea.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(get_qualified_locale.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(getqloc_downlevel.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(winapi_thunks.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(free_base.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(mbctype.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(exception_filter.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(new_handler.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(wsetlocale.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(comparestringa.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(winapi_thunks.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(invalid_parameter.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(invalid_parameter.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(environment_initialization.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(new_handler.obj) : error LNK2001: unresolved external symbol ___security_cookie
libucrt.lib(wsetlocale.obj) : error LNK2019: unresolved external symbol ___report_rangecheckfailure referenced in function __wsetlocale_nolock
libucrt.lib(comparestringa.obj) : error LNK2019: unresolved external symbol __alloca_probe_16 referenced in function "int __cdecl InternalCompareStringA(struct __crt_locale_pointers *,wchar_t const *,unsigned long,char const *,int,char const *,int,int)" (?InternalCompareStringA@@YAHPAU__crt_locale_pointers@@PB_WKPBDH2HH@Z)
libucrt.lib(getstringtypea.obj) : error LNK2001: unresolved external symbol __alloca_probe_16
libucrt.lib(lcmapstringa.obj) : error LNK2001: unresolved external symbol __alloca_probe_16
libucrt.lib(getlocaleinfoa.obj) : error LNK2001: unresolved external symbol __alloca_probe_16
libucrt.lib(exit.obj) : error LNK2019: unresolved external symbol __SEH_epilog4_GS referenced in function "public: __thiscall <lambda_6e4b09c48022b2350581041d5f6b0c4c>::operator()(void)const " (??R<lambda_6e4b09c48022b2350581041d5f6b0c4c>@@QBE@XZ)
libucrt.lib(signal.obj) : error LNK2001: unresolved external symbol __SEH_epilog4_GS
libucrt.lib(terminate.obj) : error LNK2001: unresolved external symbol __SEH_epilog4_GS
libucrt.lib(exit.obj) : error LNK2019: unresolved external symbol __SEH_prolog4_GS referenced in function "public: __thiscall <lambda_6e4b09c48022b2350581041d5f6b0c4c>::operator()(void)const " (??R<lambda_6e4b09c48022b2350581041d5f6b0c4c>@@QBE@XZ)
libucrt.lib(signal.obj) : error LNK2001: unresolved external symbol __SEH_prolog4_GS
libucrt.lib(terminate.obj) : error LNK2001: unresolved external symbol __SEH_prolog4_GS
libucrt.lib(exit.obj) : error LNK2001: unresolved external symbol ___xp_a
libucrt.lib(exit.obj) : error LNK2001: unresolved external symbol ___xp_z
libucrt.lib(exit.obj) : error LNK2001: unresolved external symbol ___xt_a
libucrt.lib(exit.obj) : error LNK2001: unresolved external symbol ___xt_z
libucrt.lib(xtoa.obj) : error LNK2019: unresolved external symbol __aulldvrm referenced in function "int __cdecl common_xtox<unsigned __int64,char>(unsigned __int64,char * const,unsigned int,unsigned int,bool)" (??$common_xtox@_KD@@YAH_KQADII_N@Z)
libucrt.lib(atox.obj) : error LNK2001: unresolved external symbol __aulldvrm
libucrt.lib(atox.obj) : error LNK2019: unresolved external symbol __allmul referenced in function "unsigned __int64 __cdecl __crt_strtox::parse_integer<unsigned __int64,class __crt_strtox::c_string_character_source<char> >(struct __crt_locale_pointers * const,class __crt_strtox::c_string_character_source<char>,int,bool)" (??$parse_integer@_KV?$c_string_character_source@D@__crt_strtox@@@__crt_strtox@@YA_KQAU__crt_locale_pointers@@V?$c_string_character_source@DH_N@Z)
libvcruntime.lib(_chandler4_.obj) : error LNK2019: unresolved external symbol __IsNonwritableInCurrentImage referenced in function __except_handler4
libvcruntime.lib(_chandler4_.obj) : error LNK2019: unresolved external symbol @_guard_check_icall@4 referenced in function __except_handler4
LINK : error LNK2001: unresolved external symbol __load_config_used
test.exe : fatal error LNK1120: 22 unresolved externals
ERROR: [Fail] 2
为了做到这一点,我已经安装了最新的 windows SDK 并设置了 INCLUDE 和 LIB 环境变量,但我对如何解决这些链接器错误有点困惑.
To get this far, I've installed the latest windows SDK and set both the INCLUDE and LIB environment variables, but I'm a bit stuck on how to solve these linker errors.
推荐答案
在我上次发帖之后.我尝试了很多方法.
after last post from me. I tried a lot of ways.
终于,我找到了解决这个问题的方法.
finally , i found how to resolve this issue.
你必须像这样使用 mkbundle:
you must use mkbundle like this:
mkbundle --deps mkbundleTest.exe -o test.exe --keeptemp
mkbundle --deps mkbundleTest.exe -o test.exe --keeptemp
重点是 --keeptemp 参数.
the point is the --keeptemp param.
使用此参数,mkbundle 会将 temp.c 文件保存在您的当前目录中.
with this param ,mkbundle will save the temp.c file on your current directory.
然后复制出这一行:
cl.exe/MT/I "C:Program Files (x86)Windows Kits8.1Includeum"/I "C:Program Files (x86)Windows Kits8.1Includeshared"/I "C:Program Files (x86)Microsoft Visual Studio 14.0VCinclude"/I "C:Program Files (x86)Monoincludemono-2.0"/I ".""temp.c" "temp.o" "C:Program Files (x86)Monolibmonosgen-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
cl.exe /MT /I "C:Program Files (x86)Windows Kits8.1Includeum" /I "C:Program Files (x86)Windows Kits8.1Includeshared" /I "C:Program Files (x86)Microsoft Visual Studio 14.0VCinclude" /I "C:Program Files (x86)Monoincludemono-2.0" /I "." "temp.c" "temp.o" "C:Program Files (x86)Monolibmonosgen-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
从该行中删除两个参数:/NODEFAULTLIB/SUBSYSTEM:windows ,
remove two params from this line: /NODEFAULTLIB /SUBSYSTEM:windows ,
最后的命令行是这样的:
the final command line like this:
cl.exe/MT/I "C:Program Files (x86)Windows Kits8.1Includeum"/I "C:Program Files (x86)Windows Kits8.1Includeshared"/I "C:Program Files (x86)Microsoft Visual Studio 14.0VCinclude"/I "C:Program Files (x86)Monoincludemono-2.0"/I ".""temp.c" "temp.o" "C:Program Files (x86)Monolibmonosgen-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
cl.exe /MT /I "C:Program Files (x86)Windows Kits8.1Includeum" /I "C:Program Files (x86)Windows Kits8.1Includeshared" /I "C:Program Files (x86)Microsoft Visual Studio 14.0VCinclude" /I "C:Program Files (x86)Monoincludemono-2.0" /I "." "temp.c" "temp.o" "C:Program Files (x86)Monolibmonosgen-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.
这种方式对我有用.
这篇关于在 Windows 上,mkbundle 因链接器错误而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!