2016-10-06 5 views
2

.NET이 설치되지 않은 환경에서 실행해야하는 콘솔 유틸리티를 빌드하려고합니다. 모노의 mkbundle은이 문제에 대한 좋은 해결책이 될 것 같다,하지만 사소한 프로젝트에 Cygwin에서를 통해 윈도우 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 @[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 사용해야합니다

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

점은 --keeptemp PARAM입니다.

이 매개 변수가 있으면 mkbundle은 temp.c 파일을 현재 디렉토리에 저장합니다.

CL.EXE/MT는/내가 \ 프로그램 파일 (86 :/I "C"를 C가 : \의 Program Files (x86) \ 윈도우 키트 \ 8.1 \ 것은 음 \ 포함 "

다음이 줄을 복사 C : \ Program Files (x86) \ Microsoft \ Visual Studio 14.0 \ VC \ include "/ I"C : \ Program Files (x86) \ 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

이 줄에서 두 PARAMS을 제거/NODEFAULTLIB/SUBSYSTEM : 창,

이 같은 최종 명령 행 :

CL.EXE/MT는/I는 "C가 : \의 Program Files (x86) \ 윈도우 키트 \ 8.1 \ 것은 음 \ 포함"/ C : \ Program Files (x86) \ Microsoft Visual Studio 14.0 \ VC \ include "/ I"C : \ Program Files (x86) \ Windows 킷 \ 8.1 \ Include \ 엑스 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 : \ Program 파일 (x 86) \ 윈도우 키트 \ 10 \ 10.0 \ 포함

+0

_does_이 빌드 된 것처럼 보입니다. 이전에 비해 훨씬 가깝습니다! 불행히도 응용 프로그램이 제대로 실행되지 않는 것 같습니다. Console.WriteLine()을 사용하는 간단한 응용 프로그램이 제대로 실행되지 않는 것 같습니다. $ ./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

좋습니다, 감사합니다! 이제 제대로 작동하는 것 같습니다. 저는 두 파일을 복사 할 필요가 없도록 정적 작업을하고 싶습니다. 그러나 그것은 다른 날과 다른 포스트를위한 연습처럼 보입니다. – Lansatac

1

그리고 난 창 10 windows10sdk을 사용하고는, 컴파일 명령은 다음과 같다 C : \ Program Files (x86) \ Microsoft Visual Studio 14.0 \ VC \ include ".14393.0 \ um"/ I "C : \ Program Files (x86) \ Windows 키트 \ 10 \ Include \ 10.0.14393.0 \ "/ 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

다음

하고 다음을 수행 행동 : C에서

  1. 복사 monosgen-2.0.dll : \ 프로그램 파일 당신의 mkbundled 응용 프로그램 디렉토리 (86) \ 모노 \ 함.

  2. C : \ Program Files (x86) \ Windows 키트 \ 10 \ Redist \ ucrt \ DLLs \ x86에서 mkbundled 응용 프로그램 디렉토리로 모든 .dll 파일을 복사하십시오. 다음 mkbundled 귀하의 응용 프로그램을 실행합니다.

원하는 결과를 얻을 수 있습니다. 또한

는 :

하고, 완전히 창문에 비 ANSI 경로를 지원하지 않기 때문에 mkbundle의 비 ANSI 경로에 당신의 번들 응용 프로그램을 넣어하지 않습니다. 이 문제를 해결하려면 temp.c 파일을 편집 할 수 있습니다.

입력 된 SetEnvironmentVariable ("UTF16"); int 주 (int argc, 문자의 *의 변수는 argv는 [])

은 다음 번들 응용 프로그램이 어떤 경로에 실행할 수 하지만 여전히 몇 가지 문제 : 메소드 본문 첫 번째 줄에 mkbundle 될 당신의 C# 응용 프로그램에서, AppDomain.CurrentDomain.BaseDirectory를 사용하여 응용 프로그램 존재 디렉토리를 가져올 수 없습니다. 및 응용 프로그램에서 app.config를 사용하고 appsettings에서 일부 변수를 정의하는 경우 다른 문제가 발생합니다. 응용 프로그램을 번들 한 후 .config 파일에서 변수를 읽을 수 없습니다. reaseon이 AppDomain.CurrentDomain.BaseDirectory 문제로 변경되었습니다.

appdomain 생성시 mkbundled 응용 프로그램으로 보이는 응용 프로그램은 ANSI가 아닌 경로를 처리 할 때 버그가 있습니다.

나는이 문제를 해결하고 모노 소스 코드를 읽었지만 지금까지 해결 방법이 없습니다.

관련 문제