交叉编译wxGtk [英] Cross-compile wxGtk

查看:121
本文介绍了交叉编译wxGtk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须交叉编译wxGtk(旧版本:2.8.11)并设法设置环境,以使 configure 成功运行.

I have to cross-compile wxGtk (an old version: 2.8.11) and managed to setup the environment so that configure runs successfully.

$ export CC=/opt/my_toolchain/toolchain_base/bin/i686-pc-linux-gnu-gcc
$ export CXX=/opt/my_toolchain/toolchain_base/bin/i686-pc-linux-gnu-g++
$ export CPPFLAGS=-I/opt/my_toolchain/additional_libs/usr/include/
$ export PKG_CONFIG_SYSROOT_DIR=/opt/my_toolchain/additional_libs/
$ export PKG_CONFIG_PATH=/opt/my_toolchain/additional_libs/usr/lib/pkgconfig
$ export PKG_CONFIG_DIR=/opt/my_toolchain/additional_libs/usr/lib/pkgconfig
$ export PKG_CONFIG_LIBDIR=/opt/my_toolchain/additional_libs/sysroot/usr/lib/
// LDFLAGS evtl falsch?? nicht ueberschreiben!?
$ export LDFLAGS="-L/opt/my_toolchain/additional_libs/lib/ -L/opt/my_toolchain/additional_libs/usr/lib/"
$ export CFLAGS="-Wl,-rpath-link=/opt/my_toolchain/additional_libs/lib/ -Wl,-rpath-link=/opt/my_toolchain/additional_libs/usr/lib/"
$ export CXXFLAGS="-Wl,-rpath-link=/opt/my_toolchain/additional_libs/lib/ -Wl,-rpath-link=/opt/my_toolchain/additional_libs/usr/lib/"
$ export LD_LIBRARY_PATH=/opt/my_toolchain/additional_libs/lib/:/opt/my_toolchain/additional_libs/usr/lib/:/opt/my_toolchain/additional_libs/usr/lib/:/opt/my_toolchain/additional_libs/lib/
$ pkg-config --define-variable=pc_path=/opt/my_toolchain/additional_libs/usr/lib/pkgconfig pkg-config

wxGTK-2.8.11 $ ./configure --enable-unicode --disable-shared --prefix=/usr/local/<targetname>
[...]
Configured wxWidgets 2.8.11 for `x86_64-unknown-linux-gnu'

Which GUI toolkit should wxWidgets use?                 GTK+ 2
Should wxWidgets be compiled into single library?       no
Should wxWidgets be compiled in debug mode?             no
Should wxWidgets be linked as a shared library?         no
Should wxWidgets be compiled in Unicode mode?           yes
What level of wxWidgets compatibility should be enabled?
                                   wxWidgets 2.4      no
                                   wxWidgets 2.6      yes
Which libraries should wxWidgets use?
                                   jpeg               sys
                                   png                sys
                                   regex              builtin
                                   tiff               sys
                                   zlib               sys
                                   odbc               no
                                   expat              sys
                                   libmspack          no
                                   sdl                no

但是随后的 make 报告错误:

wxGTK-2.8.11 $ make
[...]
bk-make-pch ./.pch/wxprec_netlib/wx/wxprec.h.gch wx/wxprec.h /opt/my_toolchain/toolchain_base/bin/i686-pc-linux-gnu-g++ -I./.pch/wxprec_netlib -D__WXGTK__     -DWXBUILDING      -I./src/regex  -DwxUSE_GUI=0 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -I/mnt/cifs/osb_m/10_Competence_Centers/21_CC_IE/22_Kunden_Technik_Aktiv/Holmer/Software/Holmer_VT-Server/wxGTK-2.8.11/lib/wx/include/gtk2-unicode-release-static-2.8 -I./include -pthread -I/opt/my_toolchain/additional_libs//usr/include/gtk-2.0 -I/opt/my_toolchain/additional_libs//usr/lib/gtk-2.0/include -I/opt/my_toolchain/additional_libs//usr/include/pango-1.0 -I/opt/my_toolchain/additional_libs//usr/include/atk-1.0 -I/opt/my_toolchain/additional_libs//usr/include/cairo -I/opt/my_toolchain/additional_libs//usr/include/pixman-1 -I/opt/my_toolchain/additional_libs//usr/include/libpng16 -I/opt/my_toolchain/additional_libs//usr/include/gdk-pixbuf-2.0 -I/opt/my_toolchain/additional_libs//usr/include/libpng16 -I/opt/my_toolchain/additional_libs//usr/include/pango-1.0 -I/opt/my_toolchain/additional_libs//usr/include/harfbuzz -I/opt/my_toolchain/additional_libs//usr/include/pango-1.0 -I/opt/my_toolchain/additional_libs//usr/include/freetype2 -I/opt/my_toolchain/additional_libs//usr/include/glib-2.0 -I/opt/my_toolchain/additional_libs//usr/lib/glib-2.0/include -I/opt/my_toolchain/additional_libs/usr/include/ -DWX_PRECOMP -pthread -Wall -Wundef -Wno-ctor-dtor-privacy -O2 -fno-strict-aliasing -Wl,-rpath-link=/opt/my_toolchain/additional_libs/lib/ -Wl,-rpath-link=/opt/my_toolchain/additional_libs/usr/lib/
In file included from /opt/my_toolchain/additional_libs/usr/include/math.h:46:0,
             from ./include/wx/math.h:19,
             from ./include/wx/wx.h:30,
             from ./include/wx/wxprec.h:68:
/opt/my_toolchain/additional_libs/usr/include/bits/mathdef.h:47:6: warning: "__FP_FAST_FMA" is not defined [-Wundef]
/opt/my_toolchain/additional_libs/usr/include/bits/mathdef.h:51:6: warning: "__FP_FAST_FMAF" is not defined [-Wundef]
/opt/my_toolchain/additional_libs/usr/include/bits/mathdef.h:55:6: warning: "__FP_FAST_FMAL" is not defined [-Wundef]
/opt/my_toolchain/toolchain_base/bin/../i686-pc-linux-gnu/libc/usr/lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status
Makefile:12022: recipe for target '.pch/wxprec_netlib/wx/wxprec.h.gch' failed
make: *** [.pch/wxprec_netlib/wx/wxprec.h.gch] Error 1

我已经打印出报告该问题的编译器命令:

I've printed the compiler command which reports the issue:

/opt/my_toolchain/toolchain_base/bin/i686-pc-linux-gnu-g++ \
-I./.pch/wxprec_baselib -D__WXGTK__ -DWXBUILDING \
-I./src/regex \
-DwxUSE_GUI=0 -DwxUSE_BASE=1 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES \
-I/path/to/wxGTK-2.8.11/lib/wx/include/gtk2-unicode-release-static-2.8 \
-I./include \
-pthread \
-I/opt/my_toolchain/additional_libs//usr/include/gtk-2.0 \
-I/opt/my_toolchain/additional_libs//usr/lib/gtk-2.0/include \
-I/opt/my_toolchain/additional_libs//usr/include/pango-1.0 \
-I/opt/my_toolchain/additional_libs//usr/include/atk-1.0 \
-I/opt/my_toolchain/additional_libs//usr/include/cairo \
-I/opt/my_toolchain/additional_libs//usr/include/pixman-1 \
-I/opt/my_toolchain/additional_libs//usr/include/libpng16 \
-I/opt/my_toolchain/additional_libs//usr/include/gdk-pixbuf-2.0 \
-I/opt/my_toolchain/additional_libs//usr/include/libpng16 \
-I/opt/my_toolchain/additional_libs//usr/include/pango-1.0 \
-I/opt/my_toolchain/additional_libs//usr/include/harfbuzz \
-I/opt/my_toolchain/additional_libs//usr/include/pango-1.0 \
-I/opt/my_toolchain/additional_libs//usr/include/freetype2 \
-I/opt/my_toolchain/additional_libs//usr/include/glib-2.0 \
-I/opt/my_toolchain/additional_libs//usr/lib/glib-2.0/include \
-I/opt/my_toolchain/additional_libs/usr/include/ \
-DWX_PRECOMP -pthread -Wall -Wundef -Wno-ctor-dtor-privacy -O2 -fno-strict-aliasing \
-Wl,-rpath-link=/opt/my_toolchain/additional_libs/lib/ \
-Wl,-rpath-link=/opt/my_toolchain/additional_libs/usr/lib/ \
-o ./.pch/wxprec_baselib/wx/wxprec.h.gch \
-MMD -MF \
./.deps/___pch_wxprec_baselib_wx_wxprec_h_gch.d \
./include/wx/wxprec.h

如果我从此编译器命令中删除了两个 -Wl,-rpath-link = 语句并手动调用它,则该命令将成功.

If I remove the two the -Wl,-rpath-link= statements from this compiler command and invoke it manually, the command succeeds.

似乎附加的 -Wl 语句使编译器使用 main()-函数(似乎是通过提供的)错过了源文件.include/wx/wxprec.h ),但我真的不知道怎么回事.

It seems the additional -Wl statements make the compiler miss the source file with the main()-function (which seems to be provided via ./include/wx/wxprec.h), but I don't really see how that could happen.

对于能解决该问题的任何建议,我将不胜感激.

I'd be grateful about any advice how I can address this problem.

更新

configure -脚本具有通常的选项(无-source )

The configure-Script has the usual options (no --source)

--build=BUILD     configure for building on BUILD [guessed]
--host=HOST       cross-compile to build programs to run on HOST [BUILD]
--target=TARGET   configure for building compilers for TARGET [HOST]

其中-target 无关紧要.我必须检查的其他选项.正如我在评论中提到的那样,到目前为止,我只看到它们与前缀一起使用,例如 aarch64-linux-gnu ,用于来自 $ PATH 中的程序包存储库中的工具链,以及相应的库等.

where --target is of no interest. The other options I'll have to check. As I mentioned in the comments, I've so far only seen them being used with prefixes e.g. aarch64-linux-gnu for toolchains from package repositories which are in the $PATH, and with according libraries etc.

因此,我已将工具链二进制文件的文件夹添加到path并配置为

So I've added the folder for toolchain binaries to path and configured with

./configure --enable-unicode --disable-shared --prefix=/usr/local/<target> --host=i686-pc-linux-gnu


configure: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used.
checking build system type... x86_64-unknown-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu

这看起来是正确的.我想在本地计算机上构建另一个目标.

That looks correct. I want to build on my local machine for another target.

但是:

checking for GTK+ - version >= 2.0.0... no
*** Could not run GTK+ test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means GTK+ is incorrectly installed.
configure: error:
The development files for GTK+ were not found. For GTK+ 2, please
ensure that pkg-config is in the path and that gtk+-2.0.pc is
installed. For GTK+ 1.2 please check that gtk-config is in the path,
and that the version is 1.2.3 or above. Also check that the
libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
--libs' are in the LD_LIBRARY_PATH or equivalent.

不幸的是,这是有道理的.工具链本身只有一些库,但没有GTK库.

Unfortunately that makes sense. The toolchain itself only has some libraries, but does not have the GTK-libraries.

/opt/my_toolchain/toolchain_base/

GTK库和其他库位于单独的文件夹中:

The GTK libraries and other libraries are in a separate folder:

/opt/my_toolchain/additional_libs/

工具链的二进制文件不知道此文件夹.

And the toolchain's binaries don't know about this folder.

我认为整个问题的出现是因为wxGtk为 host = i686-pc-linux-gnu 构建库,而且还构建了可执行文件(例如 wx-配置),用于 build-system = x86_64-unknown-linux-gnu .

I think the whole issue arises because wxGtk builds libraries for the host = i686-pc-linux-gnu, but also builds executables (e.g. wx-config) for the build-system = x86_64-unknown-linux-gnu.

推荐答案

wxGtk 2.8.11跨版本终于可以使用以下设置了:

The wxGtk 2.8.11 cross-build is finally working with the following setup:

export PATH=/opt/my_toolchain/toolchain_base/bin/:${PATH}
export PKG_CONFIG_SYSROOT_DIR=/opt/my_toolchain/additional_libs
export PKG_CONFIG_PATH=/opt/my_toolchain/additional_libs/usr/lib/pkgconfig
export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1
# make sure those env vars are not left from previous setup
unset  CC
unset  CXX
unset  CPPFLAGS
unset  CFLAGS
unset  CXXFLAGS
unset  LD_LIBRARY_PATH
unset  LDFLAGS
unset  PKG_CONFIG_DIR
unset  PKG_CONFIG_LIBDIR

./configure --enable-unicode --disable-shared --prefix=/usr/local/<target> --host=i686-pc-linux-gnu --build=x86_64-linux-gnu
make
sudo make install

这篇关于交叉编译wxGtk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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