本文介绍了Mac OS X下的Mono 3.4.0 mkbundle失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在不需要OS运行时的MAC OS X 10.9(Mavericks)下制作静态二进制文件.这几乎是干净的机器,具有最新的更新和最新的XCode.

I`m trying to make static binary under MAC OS X 10.9 (Mavericks) which is not require mono runtime. This is almost clean machine with the latest updates and the latest XCode.

如果我未设置构建体系结构,则将具有以下内容:

mkbundle client-patcher.exe -o client-patcher
OS is: Darwin
Sources: 1 Auto-dependencies: False
   embedding: /Users/radubalan/tmp/client-patcher.exe
Compiling:
as -o temp.o temp.s
cc -g -o client-patcher -Wall temp.c `pkg-config --cflags --libs mono-2`  temp.o
ld: warning: ignoring file /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/libmono-2.0.dylib, file was built for i386 which is not the architecture being linked (x86_64): /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/libmono-2.0.dylib
Undefined symbols for architecture x86_64:
  "_mono_main", referenced from:
      _main in temp-b1f73b.o
  "_mono_register_bundled_assemblies", referenced from:
      _mono_mkbundle_init in temp-b1f73b.o
  "_mono_set_dirs", referenced from:
      _main in temp-b1f73b.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ERROR: [Fail]

如果我通过以下方式设置体系结构

export AS="as -arch i386"
export CC="cc -arch i386"

我得到以下信息:

mkbundle --deps --static -z client-patcher.exe -o client-patcher
OS is: Darwin
Note that statically linking the LGPL Mono runtime has more licensing restrictions than dynamically linking.
See http://www.mono-project.com/Licensing for details on licensing.
Sources: 1 Auto-dependencies: True
   embedding: /Users/radubalan/tmp/client-patcher.exe
   compression ratio: 40.59%
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/4.5/mscorlib.dll
   compression ratio: 35.01%
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll
   compression ratio: 38.06%
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/Mono.Security/4.0.0.0__0738eb9f132ed756/Mono.Security.dll
   compression ratio: 39.97%
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
   compression ratio: 39.97%
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll
   compression ratio: 33.85%
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.Security/4.0.0.0__b03f5f7f11d50a3a/System.Security.dll
   compression ratio: 39.20%
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll
   compression ratio: 35.41%
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/Mono.Posix/4.0.0.0__0738eb9f132ed756/Mono.Posix.dll
   compression ratio: 39.91%
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.Windows.Forms/4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
   compression ratio: 35.15%
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
   compression ratio: 35.64%
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/Mono.WebBrowser/4.0.0.0__0738eb9f132ed756/Mono.WebBrowser.dll
   compression ratio: 35.01%
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.Runtime.Serialization.Formatters.Soap/4.0.0.0__b03f5f7f11d50a3a/System.Runtime.Serialization.Formatters.Soap.dll
   compression ratio: 41.03%
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/Accessibility/4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
   compression ratio: 29.55%
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.Data/4.0.0.0__b77a5c561934e089/System.Data.dll
   compression ratio: 35.13%
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/Mono.Data.Tds/4.0.0.0__0738eb9f132ed756/Mono.Data.Tds.dll
   compression ratio: 38.53%
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.Transactions/4.0.0.0__b77a5c561934e089/System.Transactions.dll
   compression ratio: 38.19%
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.EnterpriseServices/4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
   compression ratio: 38.41%
Compiling:
as -arch i386 -o temp.o temp.s
cc -arch i386 -o client-patcher -Wall `pkg-config --cflags mono-2` temp.c -lz `pkg-config --libs-only-L mono-2` `pkg-config --variable=libdir mono-2`/libmono-2.0.a `pkg-config --libs-only-l mono-2 | sed -e "s/\-lmono-2.0 //"` temp.o
Undefined symbols for architecture i386:
  "_CFLocaleCopyCurrent", referenced from:
      _ves_icall_System_Globalization_CultureInfo_get_current_locale_name in libmono-2.0.a(libmonoruntime_la-locales.o)
  "_CFLocaleGetIdentifier", referenced from:
      _ves_icall_System_Globalization_CultureInfo_get_current_locale_name in libmono-2.0.a(libmonoruntime_la-locales.o)
  "_CFLocaleGetValue", referenced from:
      _ves_icall_System_Globalization_CultureInfo_get_current_locale_name in libmono-2.0.a(libmonoruntime_la-locales.o)
  "_CFRelease", referenced from:
      _ves_icall_System_Globalization_CultureInfo_get_current_locale_name in libmono-2.0.a(libmonoruntime_la-locales.o)
  "_CFStringGetBytes", referenced from:
      _ves_icall_System_Globalization_CultureInfo_get_current_locale_name in libmono-2.0.a(libmonoruntime_la-locales.o)
  "_CFStringGetCString", referenced from:
      _ves_icall_System_Globalization_CultureInfo_get_current_locale_name in libmono-2.0.a(libmonoruntime_la-locales.o)
  "_CFStringGetLength", referenced from:
      _ves_icall_System_Globalization_CultureInfo_get_current_locale_name in libmono-2.0.a(libmonoruntime_la-locales.o)
  "_CFStringGetMaximumSizeForEncoding", referenced from:
      _ves_icall_System_Globalization_CultureInfo_get_current_locale_name in libmono-2.0.a(libmonoruntime_la-locales.o)
  "_class_addMethod", referenced from:
      _mono_threads_init_dead_letter in libmono-2.0.a(mono-threads-mach-helper.o)
  "_iconv", referenced from:
      _monoeg_g_iconv in libmono-2.0.a(libeglib_la-giconv.o)
     (maybe you meant: _monoeg_g_iconv_close, _monoeg_g_iconv_open , _monoeg_g_iconv )
  "_iconv_close", referenced from:
      _monoeg_g_iconv_close in libmono-2.0.a(libeglib_la-giconv.o)
      _monoeg_g_convert in libmono-2.0.a(libeglib_la-giconv.o)
     (maybe you meant: _monoeg_g_iconv_close)
  "_iconv_open", referenced from:
      _monoeg_g_iconv_open in libmono-2.0.a(libeglib_la-giconv.o)
     (maybe you meant: _monoeg_g_iconv_open)
  "_kCFLocaleCountryCode", referenced from:
      _ves_icall_System_Globalization_CultureInfo_get_current_locale_name in libmono-2.0.a(libmonoruntime_la-locales.o)
  "_kCFLocaleLanguageCode", referenced from:
      _ves_icall_System_Globalization_CultureInfo_get_current_locale_name in libmono-2.0.a(libmonoruntime_la-locales.o)
  "_kCFLocaleScriptCode", referenced from:
      _ves_icall_System_Globalization_CultureInfo_get_current_locale_name in libmono-2.0.a(libmonoruntime_la-locales.o)
  "_locale_charset", referenced from:
      _monoeg_g_get_charset in libmono-2.0.a(libeglib_la-gunicode.o)
      _monoeg_g_locale_from_utf8 in libmono-2.0.a(libeglib_la-gunicode.o)
      _monoeg_g_locale_to_utf8 in libmono-2.0.a(libeglib_la-gunicode.o)
  "_objc_allocateClassPair", referenced from:
      _mono_threads_init_dead_letter in libmono-2.0.a(mono-threads-mach-helper.o)
  "_objc_getClass", referenced from:
      _mono_threads_init_dead_letter in libmono-2.0.a(mono-threads-mach-helper.o)
  "_objc_msgSend", referenced from:
      _mono_threads_install_dead_letter in libmono-2.0.a(mono-threads-mach-helper.o)
      _mono_threads_init_dead_letter in libmono-2.0.a(mono-threads-mach-helper.o)
  "_objc_msgSendSuper", referenced from:
      _mono_dead_letter_dealloc in libmono-2.0.a(mono-threads-mach-helper.o)
  "_objc_registerClassPair", referenced from:
      _mono_threads_init_dead_letter in libmono-2.0.a(mono-threads-mach-helper.o)
  "_sel_registerName", referenced from:
      _mono_threads_init_dead_letter in libmono-2.0.a(mono-threads-mach-helper.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ERROR: [Fail]

单声道版本为:

mono --version
Mono JIT compiler version 3.4.0 ((no/d4511ef Tue Mar 25 14:35:52 EDT 2014)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           normal
        SIGSEGV:       altstack
        Notification:  kqueue
        Architecture:  x86
        Disabled:      none
        Misc:          softdebug
        LLVM:          yes(3.4svn-mono-(no/e656cac)
        GC:            sgen

是否可以在Mac OS X下完全打破与MRE无关的捆绑软件?

在Linux(Debian)下产生的同一个捆绑软件没有任何问题.

The same bundle under Linux (Debian) is produced without any problems.

提前谢谢!

推荐答案

要澄清,您需要在最后一个cc命令中添加以下内容:

To clarify, you need to add the following to that last cc command:

-framework CoreFoundation -lobjc -liconv

因此,在您的情况下,命令:

So in your case the command:

cc -arch i386 -o client-patcher -Wall pkg-config --cflags mono-2 temp.c -lz pkg-config --libs-only-L mono-2 pkg-config --variable=libdir mono-2/libmono-2.0.a pkg-config --libs-only-l mono-2 | sed -e "s/\-lmono-2.0 //" temp.o

应使用cc前面的那些标志重新编写:

Should be re-written with those flags in front of cc:

cc -framework CoreFoundation -lobjc -liconv -arch i386 -o客户端修补程序-Wall pkg-config --cflags mono-2 temp.c -lz pkg-config --libs-only-L mono-2 pkg- config --variable = libdir mono-2/libmono-2.0.a pkg-config --libs-only-l mono-2 | sed -e"s/-lmono-2.0//" temp.o

cc -framework CoreFoundation -lobjc -liconv -arch i386 -o client-patcher -Wall pkg-config --cflags mono-2 temp.c -lz pkg-config --libs-only-L mono-2 pkg-config --variable=libdir mono-2/libmono-2.0.a pkg-config --libs-only-l mono-2 | sed -e "s/-lmono-2.0 //" temp.o

只需剪切/粘贴上一个cc命令,将这些标志添加到其中,然后剪切/粘贴回终端,按Enter键即可.

Simply cut/paste that last cc command, add those flags to it, cut/paste back into the terminal, hit enter and enjoy.

这篇关于Mac OS X下的Mono 3.4.0 mkbundle失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 06:44