[英]C: GTK+ 3.0 (3.20) - Cross-Compile from GNU/Linux (Arch Linux) to Windows
I need to cross-compile GTK+ application from GNU/Linux (Arch Linux) to Windows. 我需要将GNU / Linux(Arch Linux)中的GTK +应用程序交叉编译到Windows。 I have already tried to use
mingw32
, but it does not see all libraries (including c's standard library!) . 我已经尝试过使用
mingw32
,但它没有看到所有的库(包括c的标准库!) 。 So, I need to: find the standard libary; 所以,我需要:找到标准的库; find all other (glib, gio, gtk, etc) libraries.
找到所有其他(glib,gio,gtk等)库。 But there's a problemm - I cannot find them.
但是有一个问题 - 我找不到它们。 I also cannot compile from Windows.
我也无法从Windows编译。 What must I do?
我必须做什么?
You can find the binaries for gtk 3 for windows on source forge or on http://win32builder.gnome.org/ . 您可以在source forge或http://win32builder.gnome.org/ 上找到适用于Windows的gtk 3的二进制文件。
Once you have extracted them, you can follow this tutorial steps: 解压缩后,您可以按照本教程中的步骤操作:
1) Install the compilation toolchain 1)安装编译工具链
Install the GCC compiler for Windows (namely MinGW, Arch Linux doc of package ): 安装适用于Windows的GCC编译器(即MinGW, Arch Linux doc of package ):
#pacman -S migw-w64
Download the latest all-in-one bundle ZIP archive directly from the official website (here's a direct link ) 直接从官方网站下载最新的一体化ZIP包存档(这里是直接链接 )
Adapt GTK+ to its location : In a terminal, move to the "gtk3-win32" folder you just created. 将GTK +调整到其位置:在终端中,移动到刚刚创建的“gtk3-win32”文件夹。 For example:
$cd /opt/gtk3-win32
then do : 例如:
$cd /opt/gtk3-win32
然后执行:
find -name '*.pc' | while read pc; do sed -e "s@^prefix=.*@prefix=$PWD@" -i "$pc"; done
2) Compile 2)编译
We will tell pkg-config
to locate GTK+3 libraries in our custom path. 我们将告诉
pkg-config
在我们的自定义路径中找到GTK + 3库。 If you extracted to /opt/gtk3-win32
: 如果您解压缩到
/opt/gtk3-win32
:
export PKG_CONFIG_PATH=/opt/gtk3-win32/lib/pkgconfig
We are ready to compile a sample C source ! 我们准备编译一个示例C源代码! Let's use a command in this style :
让我们使用这种风格的命令:
i586-mingw32msvc-gcc source.c -o executable.exe `pkg-config --cflags --libs gtk+-3.0
A new executable should have been created if everything went well. 如果一切顺利,应该创建一个新的可执行文件。 It won't run on our Linux system, because it's targeting Windows !
它不会在我们的Linux系统上运行,因为它的目标是Windows!
3) Release 3)发布
Create a folder containing the binary and the Windows .dll files. 创建一个包含二进制文件和Windows .dll文件的文件夹。 If you extracted to
/opt/gtk3-win32
: 如果您解压缩到
/opt/gtk3-win32
:
mkdir ~/distri cp executable.exe ~/distri cp /opt/gtk3-win32/bin/*.dll ~/distri
Here we go ! 开始了 ! Transfer this folder to a Windows box.
将此文件夹传输到Windows框。 Double-click on the executable and...
双击可执行文件并...
The following instructions are for gcc 5.3.0 (thread model: posix) and gtk+ 3.20.4 以下说明适用于gcc 5.3.0(线程模型:posix)和gtk + 3.20.4
After installation, in msys2 shell 安装完成后,在msys2 shell中
pacman -S mingw-w64-i686-gtk3
cd /mingw32
tar cfz c:/temp/mingw32.tar.gz
For gcc 5.3.0, edit /etc/pacman.conf 对于gcc 5.3.0,编辑/etc/pacman.conf
[core]
Server = https://archive.archlinux.org/repos/2016/05/10/$repo/os/$arch
[extra]
Server = https://archive.archlinux.org/repos/2016/05/10/$repo/os/$arch
[community]
Server = https://archive.archlinux.org/repos/2016/05/10/$repo/os/$arch
In case of upgrade 在升级的情况下
pacman -Syu
In case of downgrade 在降级的情况下
pacman -Syyuu
Later Arch Linux version seem to have gcc 6.1.1 that might be incompatible with msys2 gcc. 后来的Arch Linux版似乎有gcc 6.1.1可能与msys2 gcc不兼容。 A virtual machine might be a good idea for an Arch Linux installation that will not be upgraded (ie no security updates).
对于不会升级的Arch Linux安装(即没有安全更新),虚拟机可能是个好主意。
Unpack mingw32.tar.gz on linux, for example /opt/mingw32 在linux上解压缩mingw32.tar.gz ,例如/ opt / mingw32
perl -pi.bak -e 's,^prefix=.*,prefix=/opt/mingw32,' /opt/mingw32/lib/pkgconfig/*.pc
For example, before executing a configure script 例如,在执行配置脚本之前
export PKG_CONFIG_PATH=/opt/mingw32/lib/pkgconfig
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.