2016-10-06 5 views
2

.NETがインストールされていない環境で実行する必要があるコンソールユーティリティを構築しようとしています。 Monoのmkbundleは、この問題に最適なソリューションであると思われるが、些細なプロジェクトにcygwinの経由でWindows 10上でmkbundle(モノラル4.6.1.3)を実行している場合、これは私が受け取る出力されます:Windowsでは、mkbundleがリンカーエラーで失敗する

$ 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 @[email protected] 
libvcruntime.lib(_exsup_.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(isctype.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(initterm.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(onexit.obj) : error LNK2001: unresolved external symbol @[email protected] 
libvcruntime.lib(_chandler4_.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(getqloc_downlevel.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(lcmapstringa.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(exit.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(getlocaleinfoa.obj) : error LNK2001: unresolved external symbol @__security_check_coo[email protected] 
libucrt.lib(exception_filter.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(initctype.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(getstringtypea.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(get_qualified_locale.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(comparestringa.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(winapi_thunks.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(free_base.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(mbctype.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(invalid_parameter.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(environment_initialization.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(new_handler.obj) : error LNK2001: unresolved external symbol @[email protected] 
libucrt.lib(wsetlocale.obj) : error LNK2001: unresolved external symbol @[email protected] 
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)" ([email protected]@[email protected]@[email protected]) 
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>@@[email protected]) 
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>@@[email protected]) 
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)" ([email protected][email protected]@[email protected]) 
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)" ([email protected][email protected]@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected][email protected]) 
libvcruntime.lib(_chandler4_.obj) : error LNK2019: unresolved external symbol __IsNonwritableInCurrentImage referenced in function __except_handler4 
libvcruntime.lib(_chandler4_.obj) : error LNK2019: unresolved external symbol @[email protected] 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環境変数の両方を設定しましたが、これらのリンカエラーを解決する方法についてはちょっと固まっています。

+0

モノのバージョンは? – knocte

+0

バージョン4.6.1.3 – Lansatac

答えて

0

最後の投稿は私からです。 私はたくさんの方法を試しました。

最後に、この問題を解決する方法を見つけました。

あなたは、このようにmkbundle使用する必要があります。ポイントは--keeptemp paramです

mkbundle --deps mkbundleTest.exe -o TEST.EXE --keeptemp

このパラメータを指定すると、mkbundleはtemp.cファイルを現在のディレクトリに保存します。

は、この行をコピーします。

cl.exeの/ MT/I "C:\プログラムファイル(x86の)\ Windowsのキット\ 8.1 \含める\ UM"/I「C:\プログラムファイル(x86のC:\ Program Files(x86)\ Microsoft Visual Studio 14.0 \ VC \ include "/ I" C:\ Program Files(x86)\ Mono \ include \ 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

このラインから2つのparamsを削除:/ NODEFAULTLIB/SUBSYSTEM:窓、このような

最後のコマンドライン:

cl.exeの/ MT/I:/ "C \プログラムファイル(x86の)\ Windowsのキット\ 8.1 \には、UM \含めます" C:\ Program Files(x86)\ Microsoft Visual Studio 14.0 \ VC \ include "/ I" C:\ Program Files(x86)\ Windows \バツ86)\ 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:\プログラムファイル(x86の)\ Windowsのキット\ 10 \ 10.0 \含める

+0

_does_が作成されているように見えますが、以前よりもはるかに近いです!残念ながら、アプリケーションは正しく動作していないようです。 $ ./mkbundleTest.exe This is a test. $ ./test.exe Lansatac

+0

申し訳ありませんが、次の操作を実行するためにmkbundleビルド後に思い出させるのを忘れていました: 1. C:\ Programからmonosgen-2.0.dllをコピーします。ファイル(x86)\ Mono \ binをmkbundledアプリケーションディレクトリにコピーします。 2. C:¥Program Files(x86)¥Windows Kits¥10¥Redist¥ucrt¥DLLs¥x86から​​すべての.dllファイルをmkbundledアプリケーションディレクトリにコピーします。 次に、mkbundledというアプリケーションを実行します。 あなたは望む結果を得るでしょう。 – azraelrabbit

+0

すごく、ありがとう!今は正しく動作するようです。 2つのファイルをコピーする必要がないように静的に作業したいと思っていますが、それは別の日と別の投稿のための演習のようです。 – Lansatac

1

と私は窓10とwindows10sdkを使用していますが、コンパイル・コマンドは次のようですC:\ Program Files(x86)\ Microsoft Visual Studio 14.0 \ VC \ include。\ 14393.0 \ um "/ I" C:¥Program Files(x86)¥Windows Kits¥10¥Include¥10.0.14393.0¥shared "/ I" "/ 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:tt2。exeファイル

して、次のアクションを実行します。

  1. Cからコピーmonosgen-2.0.dll:あなたのmkbundledアプリケーションディレクトリに\プログラムファイル(x86の)は\モノ\ビンを。

  2. C:\ Program Files(x86)\ Windowsキット\ 10 \ Redist \ ucrt \ DLLs \ x86から​​mkbundledアプリケーションディレクトリにすべての.dllファイルをコピーします。 mkbundledしてあなたのアプリケーションを実行します。

あなたが望む結果を得るでしょう。

も:理由mkbundleの

と、非ANSIパスへのあなたのバンドルされたアプリケーションを入れていない、 は完全にWindows上の非ANSIのパスをサポートしていません。この問題をRESOLVする : あなたは、

SetEnvironmentVariable( "UTF16")型付け

をtemp.cファイルを編集することができます。その後、あなたのバンドルされたアプリケーションは、任意のパスで実行することができますint型のmain(int型のargc、char型*のARGV [])

、 しかしそこにまだいくつかの問題:メソッド本体の最初の行で mkbundleなるためにあなたのC#アプリケーションで 、 AppDomain.CurrentDomain.BaseDirectoryを使用して、アプリケーションが存在するディレクトリを取得することはできません。 と、アプリケーションでapp.configを使用し、appsettingsにいくつかの変数を定義している場合は別の問題です。 アプリケーションをバンドルした後、.configファイルから変数を読み取ることができません。 reaseonはAppDomain.CurrentDomain.BaseDirectoryの問題と同じです。

appdomainの作成時にmkbundledアプリケーションに見えるのは、非ANSIパスを処理するときにバグがあります。

私はこの問題を解決し、モノソースコードを読むことができますが、これまで解決策が見つかりませんでした。

関連する問題