On May 7, 1:01 pm, Danick <[EMAIL PROTECTED]> wrote:
> On Mar 12, 4:11 am, [EMAIL PROTECTED] wrote:
>
>
>
> > //thanks a lot to Torisugari, Benjamin Smedberg, Emil Wikström & all
> > mozilla dev docs, thank you all
>
> > #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;
>
> > static gboolean delete_event( GtkWidget *widget, GdkEvent *event,
> > gpointer data ) {
> >         gtk_main_quit();
> >         return FALSE;
>
> > }
>
> > 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/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"),
> > 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("XRE_InitEmbedding\n");
> >         }
> >         webBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv);
> >         if (NS_FAILED(rv)) {
> >                 printf("do_CreateInstance webBrowser\n");
> >         }
> >         baseWindow = do_QueryInterface(webBrowser);
> >         rv = baseWindow->InitWindow(window, 0, 0, 0, 300, 400);
> >         if (NS_FAILED(rv)) {
> >                 printf("InitWindow\n");
> >         }
> >         rv = baseWindow->Create();
> >         if (NS_FAILED(rv)) {
> >                 printf("Create\n");
> >         }
> >         rv =baseWindow->SetVisibility(PR_TRUE);
> >         if (NS_FAILED(rv)) {
> >                 printf("SetVisibility\n");
> >         }
> >         webNavigation = do_QueryInterface(webBrowser);
> >         rv = 
> > webNavigation->LoadURI(NS_ConvertASCIItoUTF16("http://www.google.com";).get(),
> > nsIWebNavigation::LOAD_FLAGS_NONE, 0, 0, 0);
> >         if (NS_FAILED(rv)) {
> >                 printf("LoadURI\n");
> >         }
> >         g_signal_connect(G_OBJECT(window), "delete_event",
> > G_CALLBACK(delete_event), 0);
> >         gtk_main();
> >         printf("exit...\n");
> >         XRE_TermEmbedding();
> >         XPCOMGlueShutdown();
> >         return 0;
>
> > }
>
> I have been trying to compile and run the example but I am running
> into some difficulties.
>
> The following lines:
>
> XRE_InitEmbeddingType XRE_InitEmbedding;
> XRE_TermEmbeddingType XRE_TermEmbedding;
>
> Give me the following errors when compiling:
>
> embed_xul.cpp:27: error: expected initializer before
> ‘XRE_InitEmbeddingType’
> embed_xul.cpp:28: error: ‘XRE_TermEmbeddingType’ does not name a type
>
> If I remove these definitions I am able to compile the application but
> I run into some linking issues as follows:
>
> embed_xul.cpp:(.text+0x3e): undefined reference to `XRE_InitEmbedding'
> embed_xul.cpp:(.text+0x4d): undefined reference to `XRE_TermEmbedding'
> embed_xul.cpp:(.text+0x1ac): undefined reference to
> `XRE_InitEmbedding'
> embed_xul.cpp:(.text+0x40a): undefined reference to
> `XRE_TermEmbedding'
>
> I have tried liking with libembed_base_s.a found under the /embedding/
> base directory of the objects folder after building firefox. This
> fixes the linking issues but now causes a segmentation fault when
> XPCOMGlueLoadXULFunctions is called.
>
> Any help would be greatly appreciated.
>
> Thanks in advance

Sorry I needed to add  -lxul not libembed_base_s.a to remove the
linking problem.
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding

Reply via email to