如何使用mingw32 for windows交叉编译gettext

时间:2013-12-18 00:00:32

标签: cross-compiling gettext glib mingw32

我正在尝试创建一个交叉编译设置,允许我为Linux,Windows,Mac和Android编译程序。但是,目前,我遇到了一个我不知道如何解决的问题,我认为是时候寻求帮助了。

我使用以下方法成功构建了libiconv:

./configure --build=x86_64-linux-gnu --host=i586-mingw32msvc --prefix=/opt/crosslibs/windows/ --enable-shared --enable-static
make
make install

当我为gettext尝试相同的事情时,它会配置所有内容,但是当我尝试制作时,我会得到以下内容:

../woe32dll/.libs/c++html-styled-ostream.o: In function `html_styled_ostream(float, long double,...)(...)':
/opt/crosslibs/windows/source/gettext-0.18.3.1/gettext-tools/gnulib-lib/html-styled-ostream.oo.c:70: undefined reference to `html_ostream_free(any_ostream_representation*)'
../woe32dll/.libs/c++html-styled-ostream.o: In function `html_styled_ostream_create':
/opt/crosslibs/windows/source/gettext-0.18.3.1/gettext-tools/gnulib-lib/html-styled-ostream.oo.c:143: undefined reference to `ostream_write_mem(any_ostream_representation*, void const*, unsigned int)'
../woe32dll/.libs/c++html-styled-ostream.o: In function `html_styled_ostream__end_use_class':
/opt/crosslibs/windows/source/gettext-0.18.3.1/gettext-tools/gnulib-lib/html-styled-ostream.oo.c:88: undefined reference to `html_ostream_end_span(any_ostream_representation*, char const*)'
../woe32dll/.libs/c++html-styled-ostream.o: In function `html_styled_ostream__begin_use_class':
/opt/crosslibs/windows/source/gettext-0.18.3.1/gettext-tools/gnulib-lib/html-styled-ostream.oo.c:81: undefined reference to `html_ostream_begin_span(any_ostream_representation*, char const*)'
../woe32dll/.libs/c++html-styled-ostream.o: In function `html_styled_ostream__flush':
/opt/crosslibs/windows/source/gettext-0.18.3.1/gettext-tools/gnulib-lib/html-styled-ostream.oo.c:64: undefined reference to `html_ostream_flush(any_ostream_representation*)'
../woe32dll/.libs/c++html-styled-ostream.o: In function `html_styled_ostream__write_mem':
/opt/crosslibs/windows/source/gettext-0.18.3.1/gettext-tools/gnulib-lib/html-styled-ostream.oo.c:58: undefined reference to `html_ostream_write_mem(any_ostream_representation*, void const*, unsigned int)'
../woe32dll/.libs/c++term-styled-ostream.o: In function `style_compute_color_value':
/opt/crosslibs/windows/source/gettext-0.18.3.1/gettext-tools/gnulib-lib/term-styled-ostream.oo.c:308: undefined reference to `term_ostream_rgb_to_color(any_ostream_representation*, int, int, int)'
../woe32dll/.libs/c++term-styled-ostream.o: In function `term_styled_ostream(float, long double,...)(...)':
/opt/crosslibs/windows/source/gettext-0.18.3.1/gettext-tools/gnulib-lib/term-styled-ostream.oo.c:107: undefined reference to `term_ostream_free(any_ostream_representation*)'
../woe32dll/.libs/c++term-styled-ostream.o: In function `term_styled_ostream__write_mem':
/opt/crosslibs/windows/source/gettext-0.18.3.1/gettext-tools/gnulib-lib/term-styled-ostream.oo.c:89: undefined reference to `term_ostream_set_color(any_ostream_representation*, int)'
/opt/crosslibs/windows/source/gettext-0.18.3.1/gettext-tools/gnulib-lib/term-styled-ostream.oo.c:90: undefined reference to `term_ostream_set_bgcolor(any_ostream_representation*, int)'
/opt/crosslibs/windows/source/gettext-0.18.3.1/gettext-tools/gnulib-lib/term-styled-ostream.oo.c:91: undefined reference to `term_ostream_set_weight(any_ostream_representation*, term_weight_t)'
/opt/crosslibs/windows/source/gettext-0.18.3.1/gettext-tools/gnulib-lib/term-styled-ostream.oo.c:92: undefined reference to `term_ostream_set_posture(any_ostream_representation*, term_posture_t)'
/opt/crosslibs/windows/source/gettext-0.18.3.1/gettext-tools/gnulib-lib/term-styled-ostream.oo.c:93: undefined reference to `term_ostream_set_underline(any_ostream_representation*, term_underline_t)'
../woe32dll/.libs/c++term-styled-ostream.o: In function `term_styled_ostream_create':
/opt/crosslibs/windows/source/gettext-0.18.3.1/gettext-tools/gnulib-lib/term-styled-ostream.oo.c:615: undefined reference to `term_ostream_free(any_ostream_representation*)'
../woe32dll/.libs/c++term-styled-ostream.o: In function `term_styled_ostream__flush':
/opt/crosslibs/windows/source/gettext-0.18.3.1/gettext-tools/gnulib-lib/term-styled-ostream.oo.c:101: undefined reference to `term_ostream_flush(any_ostream_representation*)'
../woe32dll/.libs/c++term-styled-ostream.o: In function `term_styled_ostream__write_mem':
/opt/crosslibs/windows/source/gettext-0.18.3.1/gettext-tools/gnulib-lib/term-styled-ostream.oo.c:95: undefined reference to `term_ostream_write_mem(any_ostream_representation*, void const*, unsigned int)'
collect2: ld returned 1 exit status
make[4]: *** [libgettextlib.la] Error 1
make[3]: *** [all] Error 2
make[2]: *** [all-recursive] Error 1
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1

以下是gettext库的configure log file链接。

目标是自己编译glib,所以我有相同的源代码用于我想要定位的所有平台。非常感谢您提供的任何帮助。

系统信息:

操作系统:Ubuntu 12.04 LTS。

我已经安装了mingw32 package

我已下载glibgettextlibiconv的来源。

我的环境配置设置为:

CFLAGS="-I/opt/crosslibs/windows/include"
CPPFLAGS="-I/opt/crosslibs/windows/include"
LDFLAGS="-L/opt/crosslibs/windows/lib"
XDG_DATA_DIRS="/opt/crosslibs/windows/share"

CC=i586-mingw32msvc-gcc
CXX=i586-mingw32msvc-g++
LD=i586-mingw32msvc-ld
RANLIB=i586-mingw32msvc-ranlib
AR=i586-mingw32msvc-ar
AS=i586-mingw32msvc-as
STRIP=i586-mingw32msvc-strip

export CFLAGS
export CPPFLAGS
export LDFLAGS
export XDG_DATA_DIRS

export CC
export CXX
export LD
export RANLIB
export AR
export AS
export STRIP

1 个答案:

答案 0 :(得分:1)

我明白了。这实际上是由gettext的构建错误引起的。这是bug report

简单的解决方法是在配置gettext之前执行以下操作。

export CFLAGS="$CFLAGS -O2" 
export CXXFLAGS="$CXXFLAGS -O2"