交叉编译wxGtk
Cross-compile wxGtk
我必须交叉编译 wxGtk(旧版本:2.8.11)并设法设置环境,以便 configure
成功运行。
$ 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
我打印了报告问题的编译器命令:
/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=
语句并手动调用它,命令就会成功。
似乎额外的 -Wl
语句使编译器错过了带有 main()
函数的源文件(这似乎是通过 ./include/wx/wxprec.h
提供的),但我没有真正看到这是怎么发生的。
如有任何解决此问题的建议,我将不胜感激。
更新
configure
-脚本有通常的选项(没有--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
中的包存储库的工具链,以及相应的库等
所以我将工具链二进制文件的文件夹添加到路径并配置为
./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
看起来正确。我想在我的本地机器上构建另一个目标。
但是:
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 库。
/opt/my_toolchain/toolchain_base/
GTK 库和其他库位于单独的文件夹中:
/opt/my_toolchain/additional_libs/
并且工具链的二进制文件不知道这个文件夹。
我认为整个问题的出现是因为 wxGtk 为 host
= i686-pc-linux-gnu
构建库,但也为 build-system
= [ 构建可执行文件(例如 wx-config
) =33=].
wxGtk 2.8.11 交叉构建终于可以使用以下设置:
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(旧版本:2.8.11)并设法设置环境,以便 configure
成功运行。
$ 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
我打印了报告问题的编译器命令:
/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=
语句并手动调用它,命令就会成功。
似乎额外的 -Wl
语句使编译器错过了带有 main()
函数的源文件(这似乎是通过 ./include/wx/wxprec.h
提供的),但我没有真正看到这是怎么发生的。
如有任何解决此问题的建议,我将不胜感激。
更新
configure
-脚本有通常的选项(没有--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
中的包存储库的工具链,以及相应的库等
所以我将工具链二进制文件的文件夹添加到路径并配置为
./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
看起来正确。我想在我的本地机器上构建另一个目标。
但是:
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 库。
/opt/my_toolchain/toolchain_base/
GTK 库和其他库位于单独的文件夹中:
/opt/my_toolchain/additional_libs/
并且工具链的二进制文件不知道这个文件夹。
我认为整个问题的出现是因为 wxGtk 为 host
= i686-pc-linux-gnu
构建库,但也为 build-system
= [ 构建可执行文件(例如 wx-config
) =33=].
wxGtk 2.8.11 交叉构建终于可以使用以下设置:
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