Embedding/NewApi/Win32

From MozillaWiki
Jump to: navigation, search

Sample using the new API and win32

This is a small test application using the win32 API and the new embedding API to implement a very rudimentary browser. You will need XULRunner headers and libraries to do this. You can build them on your own, or use XULRunner's SDK (see bottom of page)

Prerequisites

  • A build of xulrunner or firefox. A debug build is recommended during development. More on building xulrunner can be found here. This is a sample mozconfig
mk_add_options MOZ_CO_PROJECT=browser,xulrunner

ac_add_options --enable-application=browser

ac_add_options --enable-debug
ac_add_options --disable-optimize
ac_add_options --enable-tests

ac_add_options --disable-installer
ac_add_options --disable-crashreporter
ac_add_options --disable-javaxpcom
ac_add_options --disable-printing
ac_add_options --disable-embedding-tests

mk_add_options MOZ_OBJDIR=@topsrcdir@/../objdir
mk_add_options MOZ_MAKE_FLAGS=-j4
  • Get the code
  • Set the environment variable GRE_HOME to point to your build's dist/bin folder

Building

There are VisualC++ solutions for both 2005 and 2008. They are found under mozembed/win32:

  • win32_test.sln for VC2005
  • win32_test_2008.sln for VC2008

Running

You need to have GRE_HOME in your path. As this might conflict with an existing firefox install, you may want to set this up in the VC debug properties. You can add a line like this under Environment:

PATH=$(GRE_HOME);$(PATH)

Using XULRunner SDK

As an alternative to building XULRunner on your own, you can use the XULRunner SDK:

  • Get it from xulrunner sdk.
  • Set GRE_HOME to point to the xulrunner-sdk/bin folder.
  • Note: The xulrunner sdk is using a patched win32 CRT (for jemalloc). This requires that you change the project settings to use the statically linked CRT (under "C/C++ > Code Generation > Runtime Library" and choose a non DLL library: /MT or /MTd)

Troubleshooting

  • If you get a compilation error about inability to find header files (such as "prtypes.h"), it means that you set the GRE_HOME variable after you loaded the solution. Environmental variables are loaded when each process starts, so exit Visual Studio (devenv.exe), make sure devenv.exe is unloaded, re-open the solution and try to rebuild.