在openSUSE-Leap-15.6-DVD-x86_64中使用gnome-builder-45.0的基本功能(三)空白Meson工程
在openSUSE-Leap-15.6-DVD-x86_64中使用gnome-builder-45.0的基本功能三空白Meson工程需要安装meson、ninja、cmake、flatpak还有SDK应用程序——工具——终端ruhongvnclocalhost:~ su -密码localhost:~ # zypper install meson ninja cmake flatpaklocalhost:~ # flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepolocalhost:~ # flatpak remote-modify flathub --urlhttps://mirror.sjtu.edu.cn/flathub参考上海交通大学软件源镜像服务https://mirrors.sjtug.sjtu.edu.cn/docs/flathub使用flathub.org网站下载是非常缓慢的改成使用mirror.sjtu.edu.cn/flathub就非常快速了ruhongvnclocalhost:~ flatpak remotes --show-details名称 标题 网址 集合标识 子集 筛选器 优先级 选项 … … 主页 图标flathub Flathub https://mirror.sjtu.edu.cn/flathub - - - 1 system … … https://flathub.org/ https://dl.flathub.org/repo/logo.svgruhongvnclocalhost:~ cat /var/lib/flatpak/repo/configlocalhost:~ # flatpak list|grep gnomeGNOME Application Platform version 45 org.gnome.Platform 45 systemlocalhost:~ # gnome-builder --versionGNOME Builder 45.0系统安装gnome-builder-45就会自动安装对应版本的org.gnome.Platform 45localhost:~ # flatpak search org.freedesktop |grep -i org.freedesktop.sdk搜索有什么SDK可以安装localhost:~ # flatpak install org.freedesktop.Sdk安装org.freedesktop.Sdk其中S要大写Looking for matches…Similar refs found for ‘org.freedesktop.Sdk’ in remote ‘flathub’ (system):runtime/org.freedesktop.Sdk/x86_64/20.08runtime/org.freedesktop.Sdk/x86_64/21.08runtime/org.freedesktop.Sdk/x86_64/22.08runtime/org.freedesktop.Sdk/x86_64/23.08runtime/org.freedesktop.Sdk/x86_64/18.08runtime/org.freedesktop.Sdk/x86_64/1.6runtime/org.freedesktop.Sdk/x86_64/24.08runtime/org.freedesktop.Sdk/x86_64/19.08runtime/org.freedesktop.Sdk/x86_64/25.08Which do you want to use (0 to abort)? [0-9]: 9 输入数字9再按回车键ID Branch Op Remote Download[✓] org.freedesktop.Platform.GL.default 25.08 i flathub 140.4 MB / 141.4 MB[✓] org.freedesktop.Platform.GL.default 25.08-extra i flathub 25.2 MB / 141.4 MB[✓] org.freedesktop.Platform.codecs-extra 25.08-extra i flathub 14.2 MB / 14.4 MB[✓] org.freedesktop.Sdk.Locale 25.08 i flathub 2.7 MB / 394.4 MB[✓] org.freedesktop.Sdk 25.08 i flathub 508.3 MB / 595.3 MBInstallation complete.选择版本数字最高的25.08耗时大约10分钟安装后占用2GB空间localhost:~ # flatpak listName Application ID Version Branch InstallationMesa …desktop.Platform.GL.default 25.3.5 25.08 systemMesa (Extra) …desktop.Platform.GL.default 25.3.5 25.08-extra systemCodecs Extra Extension …sktop.Platform.codecs-extra 25.08-extra systemFreedesktop SDK org.freedesktop.Sdk freedesktop-sdk-25.08.8 25.08 systemGNOME Application Plat… org.gnome.Platform 45 system应用程序——编程——构建器——最下方创建新工程——工程名称multiplication_table_meson——应用程序ID:org.example.multiplication_table_meson——模板——空白Meson工程——创建工程打开src/main.c把它换成以下打印乘法口决multiplication_table的C程序组合键CtrlS保存ruhongvnclocalhost:~ cat /home/ruhongvnc/工程/multiplication_table_meson/src/main.c#includeconfig.h#includestdio.h#includeglib.h#includestdlib.hgintmain(gint argc,gchar*argv[]){inti,j;g_autoptr(GOptionContext)contextNULL;g_autoptr(GError)errorNULL;gboolean versionFALSE;GOptionEntry main_entries[]{{version,0,0,G_OPTION_ARG_NONE,version,Show program version},{NULL}};contextg_option_context_new(- my command line tool);g_option_context_add_main_entries(context,main_entries,NULL);if(!g_option_context_parse(context,argc,argv,error)){g_printerr(%s\n,error-message);returnEXIT_FAILURE;}if(version){g_printerr(%s\n,PACKAGE_VERSION);returnEXIT_SUCCESS;}printf(9x9 乘法口诀表:\n);for(i1;i9;i){for(j1;ji;j){printf(%d*%d%d\t,j,i,i*j);}printf(\n);// 每打印完一行后换行}returnEXIT_SUCCESS;}提示安装org.freedesktop.Platform/x86_64/22.08——取消单击最上方铁锤图标旁边的倒三角图标——配置工程——配置——org.example.multiplication_table_meson——位置——源码树内部——运行时——org.freedesktop.Platform/x86_64/25.08其实就是修改org.example.multiplication_table_meson.json文件右上角三根横线——首选项——左下角SDKs——可用SDK默认或者源码树外部编译出执行文件存放的路径是/home/ruhongvnc/.cache/gnome-builder/projects/multiplication_table_meson/builds/org.example.multiplication_table_meson.json-flatpak-org.freedesktop.Platform-25.08-x86_64-main/src/multiplication_table_meson源码树内部编译出执行文件存放的路径是/home/ruhongvnc/工程/multiplication_table_meson/_build/src/multiplication_table_meson单击最上方铁锤图标编译程序multiplication_table_meson单击最上方第二个三角图标运行程序multiplication_table_meson打印乘法口决表单击最上方第三个三角图标——选择运行命令——运行命令——自动发现或者multiplication_table_meson单击最上方铁锤图标旁边的倒三角图标——清理单击最上方铁锤图标旁边的倒三角图标——重新构建删除SDK文件的命令localhost:~ # flatpak uninstall --unused或者localhost:~ # flatpak uninstall org.freedesktop.Sdk\ ID Branch Op\ 1. org.freedesktop.Sdk 25.08 r\ 2. org.freedesktop.Sdk.Locale 25.08 r\ 3. org.freedesktop.Platform.codecs-extra 25.08-extra rProceed with these changes to the system installation? [Y/n]: Y 输入大写字母Y再按回车键