在Windows上,mkbundle失败,并显示链接器错误 [英] On Windows, mkbundle fails with linker error

查看:145
本文介绍了在Windows上,mkbundle失败,并显示链接器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个控制台实用程序,该实用程序需要在可能未安装.NET的环境中运行. Mono的mkbundle似乎是解决此问题的好方法,但是当在Windows 10上通过cygwin在一个琐碎的项目上运行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:\Users\Jason\Documents\mkbundleTest\mkbundleTest\bin\Debug\mkbundleTest.exe
 config from: C:\Users\Jason\Documents\mkbundleTest\mkbundleTest\bin\Debug\mkbundleTest.exe.config
   embedding: C:\Program Files\Mono\lib\mono\4.5\mscorlib.dll
AS = as (default)
as -o temp.o temp.s
Compiling:
CC = cl.exe (default)
WINSDK = C:\Program Files (x86)\Windows Kits\8.1 (default)
VSINCLUDE = C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC (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 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
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)\Mono\lib\monosgen-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@D@0@H_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 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

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

从此行中删除两个参数:/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 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

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.

以这种方式为我工作.

这篇关于在Windows上,mkbundle失败,并显示链接器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆