Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problems cross-compiling from linux to mingw32

6 views
Skip to first unread message

Marie Kesquetta

unread,
Feb 6, 2009, 10:30:19 AM2/6/09
to
Hi,

I am having a hard time trying to compile Firefox from Linux to mingw
w32 target.

My cross-compiler has been compiled successfully and installed in its
own directory (not to interfere with my regular host compiler).

Running 'make -f client.mk build' in the mozilla source directory, i get
this:

...
Building deps for /home/mig/eclipse.workspace/mingw32/mozilla/js/src/jsapi.c
i686-mingw32-gcc -mno-cygwin -o jsapi.o -c -DOSTYPE=\"WINNT\"
-DOSARCH=WINNT -DEXPORT_JS_API -DJS_USE_SAFE_ARENA
-I/home/mig/eclipse.workspace/mingw32/mozilla/js/src -I.
-I../../dist/include -I../../dist/include/js -I../../dist/include/nspr
-I../../dist/sdk/include
-I/home/mig/eclipse.workspace/mingw32/mozilla/js/src -I/usr/include
-DMOZ_DISABLE_XPCOM_STDCALL -I/usr/include -Wall -W -Wno-unused
-Wpointer-arith -Wcast-align -W -Wno-long-long -pedantic
-fno-strict-aliasing -mms-bitfields -pipe -DDEBUG -D_DEBUG -DDEBUG_mig
-DTRACING -g -DMOZ_DISABLE_XPCOM_STDCALL -I/usr/include
-DCROSS_COMPILE=1 -DWINVER=0x501 -D_WIN32_WINNT=0x501 -D_WIN32_IE=0x0500
-DMOZILLA_VERSION=\"1.9.0.2\" -DMOZILLA_VERSION_U=1.9.0.2
-DHAVE_SNPRINTF=1 -D_WINDOWS=1 -D_WIN32=1 -DWIN32=1 -DXP_WIN=1
-DXP_WIN32=1 -DHW_THREADS=1 -DSTDC_HEADERS=1 -DWIN32_LEAN_AND_MEAN=1
-DNO_X11=1 -D_X86_=1 -DD_INO=d_ino -DSTDC_HEADERS=1 -DHAVE_ST_BLKSIZE=1
-DHAVE_SIGINFO_T=1 -DHAVE_INT16_T=1 -DHAVE_INT32_T=1 -DHAVE_INT64_T=1
-DHAVE_UINT=1 -DHAVE_UNAME_US_DOMAINNAME_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=1
-DHAVE__UNWIND_BACKTRACE=1 -DMOZ_USER_DIR=\"Mozilla\" -DHAVE_STDINT_H=1
-DHAVE_INTTYPES_H=1 -DMOZ_TREE_CAIRO=1 -DHAVE_UINT64_T=1 -DMOZ_XUL=1
-DMOZ_PROFILELOCKING=1 -DMOZ_RDF=1 -DMOZ_MORKREADER=1
-DMOZ_DLL_SUFFIX=\".dll\" -DJS_THREADSAFE=1 -DMOZ_REFLOW_PERF=1
-DMOZ_REFLOW_PERF_DSP=1 -DMOZILLA_LOCALE_VERSION=\"1.9a1\"
-DMOZILLA_REGION_VERSION=\"1.9a1\" -DMOZILLA_SKIN_VERSION=\"1.8\"
-D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT
/home/mig/eclipse.workspace/mingw32/mozilla/js/src/jsapi.c
In file included from /usr/include/stdlib.h:320,
from
/home/mig/eclipse.workspace/mingw32/mozilla/js/src/jsapi.c:50:
/usr/include/sys/types.h:153: error: conflicting types for ‘uint’
/home/mig/eclipse.workspace/mingw32/mozilla/js/src/jsapi.c:46: error:
previous declaration of ‘uint’ was here
...

The problem is that while my gcc cross-compiler has been installed from
/home/mig/eclipse.workspace/mingw32 with include files in
/home/mig/eclipse.workspace/mingw32/include, the mozilla build system
still tries to get my host include files (using "-I/usr/include"). I
would expect instead "-I/home/mig/eclipse.workspace/mingw32/include".

My mozconfig file is:

"""
CROSS_COMPILE=1
ac_add_options --enable-application=browser
ac_add_options --host=i686-linux
ac_add_options --target=i686-mingw32
ac_add_options --enable-default-toolkit=cairo-windows


ac_add_options --prefix=/home/mig/eclipse.workspace/mingw32
ac_add_options --libdir=/home/mig/eclipse.workspace/mingw32/lib
ac_add_options --includedir=/home/mig/eclipse.workspace/mingw32/include

ac_add_options --disable-static
ac_add_options --enable-shared

mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../mozilla-mingw

# Mozilla trunk uses many Vista only features on Windows, so we should
disable some components to make it buildable with mingw32.
ac_add_options --enable-debug
ac_add_options --disable-optimize
ac_add_options --disable-tests
ac_add_options --disable-embedding-tests
ac_add_options --disable-installer
ac_add_options --disable-accessibility

ac_add_options --disable-vista-sdk-requirements
ac_add_options --disable-updater

#change this to where your libIDL-config file locate.
HOST_LIBIDL_CONFIG=/usr/bin/libIDL-config-2
#Config your moztools position
GLIB_PREFIX=/home/mig/eclipse.workspace/mingw32/moztools
LIBIDL_PREFIX=/home/mig/eclipse.workspace/mingw32/moztools

#disable xpcom stdcall calling convention because of gcc 4.3.0 bug
CPPFLAGS="-DMOZ_DISABLE_XPCOM_STDCALL"
"""

What did i miss ? How can i tell the mozilla build system where to take
its include files from ?

Thanks.

Benjamin Smedberg

unread,
Feb 6, 2009, 11:00:05 AM2/6/09
to
On 2/6/09 10:30 AM, Marie Kesquetta wrote:
> Hi,
>
> I am having a hard time trying to compile Firefox from Linux to mingw
> w32 target.

You seem to be following the instructions at
https://developer.mozilla.org/en/Cross_Compile_Mozilla_for_Mingw32 , which
is good.

> My cross-compiler has been compiled successfully and installed in its
> own directory (not to interfere with my regular host compiler).

What does cross-compiler-cpp -v say your include search path is?

> The problem is that while my gcc cross-compiler has been installed from
> /home/mig/eclipse.workspace/mingw32 with include files in
> /home/mig/eclipse.workspace/mingw32/include, the mozilla build system
> still tries to get my host include files (using "-I/usr/include"). I
> would expect instead "-I/home/mig/eclipse.workspace/mingw32/include".

> -I/home/mig/eclipse.workspace/mingw32/mozilla/js/src -I/usr/include

The expliict -I/usr/include probably come from configure checks and
pkgconfig. You probably need to set PKG_CONFIG_PATH to the location of your
cross-compile prefix/lib/pkgconfig

See, for an example:
https://developer.mozilla.org/en/Compiling_32-bit_Firefox_on_a_Linux_64-bit_OS#Configuration

> My mozconfig file is:

Nowhere in this mozconfig do I see you setting CC and CXX. Are they in your
PATH? Is configure detecting them correctly? It seems likely that configure
is detecting the system compiler 'gcc' and 'g++' instead of your cross compiler.

The best thing is to explicitly set CC, CXX, AR, etc to your cross-compile
binaries.

> ac_add_options --enable-default-toolkit=cairo-windows

You should probably leave this out, it is the default.

> ac_add_options --prefix=/home/mig/eclipse.workspace/mingw32
> ac_add_options --libdir=/home/mig/eclipse.workspace/mingw32/lib
> ac_add_options --includedir=/home/mig/eclipse.workspace/mingw32/include

You are mis-using --prefix here. --prefix indicates where the package should
be installed on the target system. It doesn't much matter on mingw32, since
you usually don't install windows packages using the linux filesystem
conventions, but these options aren't doing what you seem to expect. You
should remove them.

> ac_add_options --disable-static
> ac_add_options --enable-shared

These are the default or meaningless. Remove them.

--BDS

Marie Kesquetta

unread,
Feb 6, 2009, 12:52:26 PM2/6/09
to Benjamin Smedberg

Many thanks for your answer Benjamin, this clarified several things.

Benjamin Smedberg wrote:
>> My cross-compiler has been compiled successfully and installed in its
>> own directory (not to interfere with my regular host compiler).
>
> What does cross-compiler-cpp -v say your include search path is?

It says:

"""
Using built-in specs.
Target: i686-mingw32
Configured with: ../gcc-4.3.0/configure
--prefix=/home/mig/eclipse.workspace/mingw32 --target=i686-mingw32
--with-gnu-ld --with-gnu-as --enable-__cxa_atexit --enable-languages=c,c++
Thread model: win32
gcc version 4.3.0 (GCC)
COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic'
/home/mig/eclipse.workspace/mingw32/libexec/gcc/i686-mingw32/4.3.0/cc1
-E -quiet -v - -mtune=generic
ignoring nonexistent directory
"/home/mig/eclipse.workspace/mingw32/lib/gcc/i686-mingw32/4.3.0/../../../../i686-mingw32/sys-include"
#include "..." search starts here:
#include <...> search starts here:
/home/mig/eclipse.workspace/mingw32/lib/gcc/i686-mingw32/4.3.0/include

/home/mig/eclipse.workspace/mingw32/lib/gcc/i686-mingw32/4.3.0/include-fixed

/home/mig/eclipse.workspace/mingw32/lib/gcc/i686-mingw32/4.3.0/../../../../i686-mingw32/include
End of search list.
"""

Apparently, this looks fine.

>> The problem is that while my gcc cross-compiler has been installed from
>> /home/mig/eclipse.workspace/mingw32 with include files in
>> /home/mig/eclipse.workspace/mingw32/include, the mozilla build system
>> still tries to get my host include files (using "-I/usr/include"). I
>> would expect instead "-I/home/mig/eclipse.workspace/mingw32/include".
>
>> -I/home/mig/eclipse.workspace/mingw32/mozilla/js/src -I/usr/include
>
> The expliict -I/usr/include probably come from configure checks and
> pkgconfig. You probably need to set PKG_CONFIG_PATH to the location of your
> cross-compile prefix/lib/pkgconfig

Ok, this is probably the source of my problem !

However, i don't have any pkgconfig directory in my cross-compile
directory and i can't figure out how to generate this. Any clue someone ?

> Nowhere in this mozconfig do I see you setting CC and CXX. Are they in your
> PATH? Is configure detecting them correctly? It seems likely that configure
> is detecting the system compiler 'gcc' and 'g++' instead of your cross compiler.
>
> The best thing is to explicitly set CC, CXX, AR, etc to your cross-compile
> binaries.

Yes, the compiler binaries are in the path and apparently are used:

"""
Building deps for /home/mig/eclipse.workspace/mingw32/mozilla/js/src/jsapi.c
i686-mingw32-gcc -mno-cygwin -o jsapi.o ...
"""

Anyway, i have added explicitely in .mozconfig:

"""
CC=i686-mingw32-gcc
CXX=i686-mingw32-g++
CPP=i686-mingw32-cpp
AS=i686-mingw32-as
LD=i686-mingw32-ld
"""

and i get the same result

>> ac_add_options --enable-default-toolkit=cairo-windows
> You should probably leave this out, it is the default.

Ok.

>> ac_add_options --prefix=/home/mig/eclipse.workspace/mingw32
>> ac_add_options --libdir=/home/mig/eclipse.workspace/mingw32/lib
>> ac_add_options --includedir=/home/mig/eclipse.workspace/mingw32/include
> You are mis-using --prefix here. --prefix indicates where the package should
> be installed on the target system. It doesn't much matter on mingw32, since
> you usually don't install windows packages using the linux filesystem
> conventions, but these options aren't doing what you seem to expect. You
> should remove them.

Correct.

>> ac_add_options --disable-static
>> ac_add_options --enable-shared
>
> These are the default or meaningless. Remove them.

Done.

Benjamin Smedberg

unread,
Feb 6, 2009, 5:07:37 PM2/6/09
to
On 2/6/09 12:52 PM, Marie Kesquetta wrote:

>> The expliict -I/usr/include probably come from configure checks and
>> pkgconfig. You probably need to set PKG_CONFIG_PATH to the location of
>> your
>> cross-compile prefix/lib/pkgconfig
>
> Ok, this is probably the source of my problem !
>
> However, i don't have any pkgconfig directory in my cross-compile
> directory and i can't figure out how to generate this. Any clue someone ?

Where do you have your cross-compile libraries installed? e.g. w32api and such?

You may end up needing to set PKG_CONFIG_PATH to some empty directory and
see what breaks when you configure.

--BDS

Marie Kesquetta

unread,
Feb 9, 2009, 10:12:52 AM2/9/09
to Benjamin Smedberg

My cross-compiler is installed in /home/mig/eclipse.workspace/mingw32,
with compiler binaries in xxx/bin (as first statement of $PATH),
libraries in xxx/lib and include files in xxx/include.

I have created an empty directory
/home/mig/eclipse.workspace/mingw32/lib/pkgconfig
and set PKG_CONFIG_PATH to it. But still, the build system wants to
include my host compiler files:

i686-mingw32-gcc -mno-cygwin -o jsapi.o -c -DOSTYPE=\"WINNT\"
-DOSARCH=WINNT -DEXPORT_JS_API -DJS_USE_SAFE_ARENA
-I/home/mig/eclipse.workspace/mingw32/mozilla/js/src -I.
-I../../dist/include -I../../dist/include/js -I../../dist/include/nspr
-I../../dist/sdk/include

-I/home/mig/eclipse.workspace/mingw32/mozilla/js/src -I/usr/include ...

Benjamin Smedberg

unread,
Feb 9, 2009, 10:26:31 AM2/9/09
to
On 2/9/09 10:12 AM, Marie Kesquetta wrote:

> I have created an empty directory
> /home/mig/eclipse.workspace/mingw32/lib/pkgconfig
> and set PKG_CONFIG_PATH to it. But still, the build system wants to
> include my host compiler files:
>
> i686-mingw32-gcc -mno-cygwin -o jsapi.o -c -DOSTYPE=\"WINNT\"
> -DOSARCH=WINNT -DEXPORT_JS_API -DJS_USE_SAFE_ARENA
> -I/home/mig/eclipse.workspace/mingw32/mozilla/js/src -I.
> -I../../dist/include -I../../dist/include/js -I../../dist/include/nspr
> -I../../dist/sdk/include
> -I/home/mig/eclipse.workspace/mingw32/mozilla/js/src -I/usr/include ...

You need to figure out where the -I/usr/include is coming from.

To do this, watch the output when you run configure. If you don't see
-I/usr/include in that output, check config.log

--BDS

Marie Kesquetta

unread,
Feb 10, 2009, 11:41:45 AM2/10/09
to Benjamin Smedberg
Benjamin Smedberg wrote:
> You need to figure out where the -I/usr/include is coming from.

I finally found out that the build system was including this directory
because this is where my X11 include files are. This is strange given
that compiling for windows, i don't need X11. Actually, the compilation
used -DNO_X11=1 but still wanted to scan the include directory.

So adding 'ac_add_options --without-x' to the .mozconfig file allowed me
to compile Firefox.

Unfortunately, the generated exe crashes quickly on windows. However, it
is more or less usable using wine on linux. So, it is a half success.

I tried to recompile entirely firefox in static:

ac_add_options --enable-static
ac_add_options --disable-shared

in case that would change something but it failed compiling:

../../gfx/cairo/cairo/src/libmozcairo.a(cairo-win32-printing-surface.o):
In function `_cairo_win32_printing_surface_paint_linear_pattern':
/home/mig/eclipse.workspace/mingw32/mozilla/gfx/cairo/cairo/src/cairo-win32-printing-surface.c:809:
undefined reference to `_GradientFill@24'

Well, even if this is far from perfect, being able to compile on linux
for windows improves greatly my development environment.

Thanks for your help Benjamin.

Benjamin Smedberg

unread,
Feb 10, 2009, 2:59:12 PM2/10/09
to
On 2/10/09 11:41 AM, Marie Kesquetta wrote:
> Benjamin Smedberg wrote:
>> You need to figure out where the -I/usr/include is coming from.
>
> I finally found out that the build system was including this directory
> because this is where my X11 include files are. This is strange given
> that compiling for windows, i don't need X11. Actually, the compilation
> used -DNO_X11=1 but still wanted to scan the include directory.
>
> So adding 'ac_add_options --without-x' to the .mozconfig file allowed me
> to compile Firefox.

This sounds like a bug. Could you please file it at bugzilla.mozilla.org? We
should disable the X checks automatically when building for a Windows target.

> I tried to recompile entirely firefox in static:
>
> ac_add_options --enable-static
> ac_add_options --disable-shared

Please don't. Thunderbird still uses this configuration but we're trying to
phase it out. It doesn't do what you think, in any case.

--BDS

Marie Kesquetta

unread,
Feb 12, 2009, 5:20:04 AM2/12/09
to Benjamin Smedberg
Benjamin Smedberg wrote:
> This sounds like a bug. Could you please file it at bugzilla.mozilla.org? We
> should disable the X checks automatically when building for a Windows target.

It's done: https://bugzilla.mozilla.org/show_bug.cgi?id=478194

Thanks.

0 new messages