クロスプラットフォームのローカルアプリ開発はC#(mono)か
Posted on 9月 23, 2008
Filed Under mac, linux, mono, クロスプラットフォーム, C++ |
「mac対応しないとか今時ねーよ」みたいなことをtypesterが言うので、調べた。
C#がいいかなぁ
What is Mono?
Mono provides the necessary software to develop and run .NET client and server applications on Linux, Solaris, Mac OS X, Windows, and Unix
今年の3月にでたMono 1.9で
# System.Media implemented.
というのもGJ
試す
debian lennyならaptパッケージがある
System.Windows.Forms使うなら
libmono-winforms2.0-cil もお忘れなく。
まずはc#でhelloworld
C#:
-
santrini% cat helloworld.cs
-
using System;
-
using System.Windows.Forms;
-
-
public class HelloWorld : Form
-
{
-
static public void Main ()
-
{
-
}
-
-
public HelloWorld ()
-
{
-
Text = "Hello Mono World";
-
}
-
}
-
santrini% gmcs helloworld.cs -r:System.Windows.Forms.dll
-
santrini% export DISPLAY=localhost:51.0; mono helloworld.exe
こんな

音の再生はこんな
WindowsのVisual C# 2008 Express EditionのテンプレートからつくったWindowsフォームアプリケーション。
C#:
-
santrini% cat Program.cs
-
using System;
-
using System.Collections.Generic;
-
using System.Linq;
-
using System.Windows.Forms;
-
-
namespace sound
-
{
-
static class Program
-
{
-
/// <summary>
-
/// アプリケーションのメイン エントリ ポイントです。
-
/// </summary>
-
[STAThread]
-
static void Main()
-
{
-
Application.EnableVisualStyles();
-
Application.SetCompatibleTextRenderingDefault(false);
-
}
-
}
-
}
-
santrini% cat Form1.cs
-
using System;
-
using System.Collections.Generic;
-
using System.ComponentModel;
-
using System.Linq;
-
using System.Text;
-
using System.Windows.Forms;
-
-
namespace sound
-
{
-
public partial class Form1 : Form
-
{
-
public Form1()
-
{
-
//player.play("/home/mo/tmp/csharp/sound/1.wav");
-
player.play("/home/mo/tmp/csharp/sound/1.mp3");
-
}
-
}
-
}
-
santrini% cat WavPlayer.cs
-
using System;
-
using System.Collections.Generic;
-
using System.Linq;
-
using System.Text;
-
using System.Media;
-
-
namespace sound
-
{
-
class WavPlayer
-
{
-
public WavPlayer()
-
{
-
}
-
-
public void play(string wavfile)
-
{
-
player.Play();
-
}
-
}
-
}
-
santrini% gmcs Program.cs Form1.cs WavPlayer.cs -r:System.Windows.Forms.dll
-
santrini% export DISPLAY=localhost:51.0; mono Program.exe
これはありだなぁ
Comments
2 Responses to “クロスプラットフォームのローカルアプリ開発はC#(mono)か”
Leave a Reply
あれれ
http://www.mono-project.com/Mono:OSX
A MacOS X specific Mono launcher was in development but its status is unclear today
コマンドラインからしか起動できないの?
Gtk#, MonoDevelop, and System.Windows.Forms applications require X11. Installing on a machine without X11 installed will result in errors during install, and these components will not function correctly.
だって、しかもX11があってもSystem.Windows.FormsはOSX10.5では動かないっぽい