I've a xulrunner C++ embedding example, it compiles and generates the
executable, but when I run it, the XRE_InitEmbedding fails. I've xulrunner
installed in /opt/xulrunner-1.9.1.4
What am I doing wrong?
This is the code:
#define XPCOM_GLUE
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <gtk/gtk.h>
#include "xpcom-config.h"
#include "nsXPCOMGlue.h"
#include "nsDebug.h"
#include "nsCOMPtr.h"
#include "widget/nsIBaseWindow.h"
#include "nsILocalFile.h"
#include "nsIWebBrowser.h"
#include "docshell/nsIWebNavigation.h"
#include "nsEmbedCID.h"
#include "nsEmbedString.h"
#include "xulapp/nsXULAppAPI.h"
#include "nsComponentManagerUtils.h"
XRE_InitEmbeddingType XRE_InitEmbedding;
XRE_TermEmbeddingType XRE_TermEmbedding;
int main(int argc, char** argv) {
GtkWidget *window;
nsCOMPtr<nsIBaseWindow> baseWindow;
nsCOMPtr<nsIWebBrowser> webBrowser;
nsCOMPtr<nsILocalFile> libxul;
nsCOMPtr<nsIWebNavigation> webNavigation;
nsDynamicFunctionLoad nsFuncs[] = {
{"XRE_InitEmbedding", (NSFuncPtr*)&XRE_InitEmbedding},
{"XRE_TermEmbedding", (NSFuncPtr*)&XRE_TermEmbedding},
{0, 0}
};
nsresult rv;
gtk_init (&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show(window);
rv = XPCOMGlueStartup("/opt/xulrunner-1.9.1.4/libxpcom.so");
if (NS_FAILED(rv)) {
printf("XPCOMGlueStartup\n");
}
rv = XPCOMGlueLoadXULFunctions(nsFuncs);
if (NS_FAILED(rv)) {
printf("XPCOMGlueLoadXULFunctions\n");
}
rv = NS_NewNativeLocalFile(nsEmbedCString("/opt/xulrunner-1.9.1.4"),
PR_FALSE, getter_AddRefs(libxul));
if (NS_FAILED(rv)) {
printf("NS_NewNativeLocalFile\n");
}
rv = XRE_InitEmbedding(libxul, 0, 0, 0, 0);
if (NS_FAILED(rv)) {
printf("Error XRE_InitEmbedding %d\n",rv);
return -1;
}
}
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding