Mkbundle无法编译在OS X C#应用程序 [英] Mkbundle failed to compile C# application on OS X

查看:266
本文介绍了Mkbundle无法编译在OS X C#应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在这个现在几天,虽然我很快设法得到Mono的mkbundle创建Windows和Linux上的本机的可执行文件我还没有能够为OS X这样做。

I've been at this for a few days now and whilst I fairly quickly managed to get Mono's mkbundle to create a native executable on Windows and Linux I haven't been able to do the same for OS X.

我使用的是单声道3.4.0,因为我需要.NET 4.5的支持,并能够编译x86_64的OS X将是很好了。

I'm using Mono 3.4.0 as I need .NET 4.5 support and being able to compile for x86_64 on OS X would be nice too.

我目前使用下面简单的bash脚本来尝试mkbundle编译:

I currently use the following simple bash script to attempt the mkbundle build:

#!/bin/bash
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig:/Library/Frameworks/Mono.framework/Versions/3.4.0/lib/pkgconfig
#PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/3.4.0/lib/pkgconfig

mkbundle bin/Release/Launcher.exe --static --deps -o bin/Release/OSXNative/Launcher.exe

我碰到下面的输出是:

I get the following output for it:

$ ./OSXNativeBuild.sh 
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: /Volumes/app/Launcher/Launcher/bin/Release/Launcher.exe
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/4.5/mscorlib.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/Mono.Security/4.0.0.0__0738eb9f132ed756/Mono.Security.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.Security/4.0.0.0__b03f5f7f11d50a3a/System.Security.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.Windows.Forms/4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/Mono.WebBrowser/4.0.0.0__0738eb9f132ed756/Mono.WebBrowser.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/Mono.Posix/4.0.0.0__0738eb9f132ed756/Mono.Posix.dll
   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
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/Accessibility/4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.Data/4.0.0.0__b77a5c561934e089/System.Data.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/Mono.Data.Tds/4.0.0.0__0738eb9f132ed756/Mono.Data.Tds.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.Transactions/4.0.0.0__b77a5c561934e089/System.Transactions.dll
   embedding: /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/gac/System.EnterpriseServices/4.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll

Compiling:
as -o temp.o temp.s 
cc -o bin/Release/OSXNative/Launcher.exe -Wall `pkg-config --cflags mono-2` temp.c  `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
ld: warning: ignoring file /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/pkgconfig/../../lib/libmono-2.0.a, file was built for archive which is not the architecture being linked (x86_64): /Library/Frameworks/Mono.framework/Versions/3.4.0/lib/pkgconfig/../../lib/libmono-2.0.a
Undefined symbols for architecture x86_64:
  "_mono_main", referenced from:
      _main in temp-I71V1m.o
  "_mono_register_bundled_assemblies", referenced from:
      _mono_mkbundle_init in temp-I71V1m.o
  "_mono_set_dirs", referenced from:
      _main in temp-I71V1m.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]

我试过

东西:

Things I've tried:

  • 我发现,除去--static参数允许mkbundle构建成功。但是,这只是移动到上述问题的运行时,我想它反正静态编译。
  • 单3.4.0发行说明何况在Mac OS X中mkbundle现在必须始终链接对Objective-C的运行。不过,我无法弄清楚如何做到这一点,它并没有什么意义,我为什么我会想这样做。
  • I found that removing the --static argument allows the mkbundle build to succeed. But that just moves to above problem to runtime, and I'd like it statically compiled anyway.
  • The Mono 3.4.0 release notes mention that mkbundle on Mac OS X now must always link against the Objective-C Runtime. However I cannot figure out how to do so and it doesn't make sense to me in why I'd want to do that.

推荐答案

我的工作出了什么问题是到底 - 只见运行到这两个新mkbundle性能要求和一些不匹配的架构设置。下面的脚本为我工作:

I worked out what the issue was in the end - I saw running into both the new mkbundle property requirements and some mismatched architecture settings. The below script worked for me:

#!/bin/bash

# Notes:
# You will need the Mono SDK 3.x series as the 2.x SDK cannot build for 64bit architectures.
# It appears that Mono 3.x still cannot compile for 64bit without having to manually compile Mono yourself.
# Since we don't strictly need 64bit support the below forces a 32bit build.

# Ensure it can find pkg-config:
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig:/Library/Frameworks/Mono.framework/Versions/3.4.0/lib/pkgconfig

# Force 32bit build and manually set some clang linker properties:
export AS="as -arch i386"
export CC="cc -arch i386 -lobjc -liconv -framework Foundation"

# Build:
mkbundle bin/Release/Launcher.exe --static --deps -o bin/Release/OSXNative/Launcher.exe

这篇关于Mkbundle无法编译在OS X C#应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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