官方优秀的开发使用说明文档
同样优秀的官方开发说明文档
1.Windows下开发环境VisualStudio2019
2.新建C#跨平台应用
3.工程解决方案右键Nuget安装Gtk3依赖
4.编写代码:
using Gtk;
using System;
namespace GeneralConsole
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Application.Init();//初始化
var win = new Window("Hello World");//新建窗体,标题是Hello World
win.SetDefaultSize(300, 600);
//窗体关闭后退出应用
win.DeleteEvent += (s, e) =>
{
Application.Quit();
};
win.WindowPosition = WindowPosition.Center;
win.Resizable = false;
var lable = new Label("This is a lable");//新建标签
win.Add(lable);//将标签加入到窗体
win.ShowAll();//显示窗体
Application.Run();//运行窗体
}
}
}
5.编译运行(编译ok,会提示下载gtk-3.24.zip)
自行下载gtk-3.24.24.zip:
http://xjp.ppsbbs.tech:8081/foot-wash/storage/app/images/downloads/gtk-3.24.24.zip
下载完成后解压在C:\Users\登陆用户\AppData\Local\Gtk\3.24.24\目录下
6.运行截图
7.发布到Linux下
右键工程->publish(发布)->选择Folder->新建profile
配置完成后,编译ok。
Linux x64安装.netcore3.1运行环境
下载环境:(Linux x64)
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=ubuntu.20.04-x64
若未安装,则提示:
$ ./GeneralConsole
A fatal error occurred. The required library libhostfxr.so could not be found.
If this is a self-contained application, that library should exist in [/home/ppshuai/gtk-run/].
If this is a framework-dependent application, install the runtime in the global location [/usr/share/dotnet] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet/install_location].
The .NET Core runtime can be found at:
- https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=ubuntu.20.04-x64
解压到Linux下的/home/dotnet/目录下。配置~/.bashrc环境变量
# Set up dotnet environment
export PATH=$PATH:$HOME/dotnet/
export DOTNET_ROOT=$HOME/dotnet/
手动生效配置:source ~/.bashrc
再次运行:
./GeneralConsole
运行成功!