I've been taking notes (below) of my latest attempt to compile
a simple embedding project (thanks to the uBrowser project
for providing a good example).
At the end is found the output of running the executable
(it finally compiles!). All the ASSERTION and failure to
load files don't look very encouraging.
I don't know if maybe I just happened to check out from CVS (HEAD)
at the wrong time. Otherwise, please let me know what I'm doing wrong.


My system is Ubuntu (Dapper), a Debian-based GNU/Linux system.
Started May 30, 2006.

Obtaining the source

[My last message was blocked because it exceeded the size limit
for message, so I'm eliding this part. In a nutshell, I got
a CVS checkout of HEAD of 'browser,xulrunner'.]

Building XULRunner

Now to build xulrunner, I followed the docs at
http://developer.mozilla.org/en/docs/XULRunner%3ABuild_Instructions .
I based my .mozconfig on their minimal one, plus reading
http://www.mozilla.org/build/configure-build.html and a bit
of http://www.ubrowser.com/howtobuild.php (great example of
an embedding app, by the way!).

mk_add_options MOZ_CO_PROJECT=xulrunner
ac_add_options --enable-application=xulrunner
mk_add_options [EMAIL PROTECTED]@/obj-xulrunner-debug
ac_add_options --disable-javaxpcom
ac_add_options --disable-optimize
ac_add_options --enable-debug

[elision to save space: make -f client.mk build]

Simple test embedding app

I made a Makefile based on one by Doug Turner for the Gecko SDK,
plus information from the ubrowser.vcproj file of the uBrowser project.
Here it is (note: tabs are important in make files).

XX = c++

XR_TARGET_DIR = target
XR_APP_NAME = test

CPPFLAGS += -g -Wall -Wno-non-virtual-dtor -fno-rtti -fno-exceptions

# Change this to point at the dist directory in your obj dir
XR_DIST = /home/slanning/mozilla/src/cvs-xulrunner/mozilla/obj-xulrunner-debug/dist

# GCC only define which allows us to not have to #include mozilla-config
# in every .cpp file.  If you're not using GCC remove this line and add
# #include "mozilla-config.h" to each of your .cpp files.
# (This is under sdk/include/)
XR_CONF_INCLUDE = -include mozilla-config.h

XR_DEFINES = -DMOZILLA_STRICT_API -DDEBUG

XR_INCLUDES = -I $(XR_DIST)/sdk/include                     \
              -I $(XR_DIST)/include/content                 \
              -I $(XR_DIST)/include/docshell                \
              -I $(XR_DIST)/include/dom                     \
              -I $(XR_DIST)/include/gfx                     \
              -I $(XR_DIST)/include/layout                  \
              -I $(XR_DIST)/include/locale                  \
              -I $(XR_DIST)/include/string                  \
              -I $(XR_DIST)/include/uriloader               \
              -I $(XR_DIST)/include/view                    \
              -I $(XR_DIST)/include/webbrwsr                \
              -I $(XR_DIST)/include/widget                  \
              -I $(XR_DIST)/include/xpcom                   \
              -I $(XR_DIST)/include/xulapp

XR_LDFLAGS =  -L $(XR_DIST)/sdk/lib -lnspr4 -lplds4 -lplc4  \
              -L $(XR_DIST)/lib     -lxpcom -lxul           \
              -L $(XR_DIST)/lib/components                  \
              -lstdc++
# for libmozjs.so needed by libxul.so
XR_LDFLAGS += -Wl,-rpath -Wl,$(XR_DIST)/lib

build:
$(CXX) -o test $(XR_CONF_INCLUDE) $(XR_DEFINES) $(XR_INCLUDES) $(XR_LDFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(XR_APP_NAME).cpp
        chmod +x $(XR_APP_NAME)

clean:
        rm $(XR_APP_NAME)
        rm -r $(XR_TARGET_DIR)

target:
        mkdir $(XR_TARGET_DIR)
        cp $(XR_APP_NAME) $(XR_TARGET_DIR)
        cp -r $(XR_DIST)/bin/* $(XR_TARGET_DIR)


The test application test.cpp is the following. It is a minimal thing
that uses XRE_InitEmbedding, as shown in uBrowser's embeddedbrowser.cpp
file (embeddedBrowser::init).

// test.cpp
// - using Makefile:
// make
// make target     # copies into 'target' directory

#include <string>
#include <iostream>
#include "nsILocalFile.h"
#include "nsXULAppAPI.h"    // XRE_InitEmbedding, XRE_TermEmbedding
#include "nsXPCOMGlue.h"
#include "nsCOMPtr.h"
#include "nsStringAPI.h"

int main (int argc, char *argv[]) {
    nsresult rv;                              // nscore.h (via nsXPCOMGlue.h)

    // copied from uBrowser
    std::string appBaseDir("/home/slanning/mozilla/src/cvs-xulrunner/target");
    std::string appDir(appBaseDir);
    std::string xulRuntimeDir(appBaseDir);

    nsCOMPtr<nsILocalFile> xuldir;
    // NS_NewNativeLocalFile is in nsXPCOM.h (via nsXULAppAPI.h)
    // PR_FALSE is from sdk/include/prtypes.h (via nscore.h)
    rv = NS_NewNativeLocalFile(nsCString(xulRuntimeDir.c_str()),
                               PR_FALSE, getter_AddRefs(xuldir));
    if (NS_FAILED(rv)) {
        std::cout << "NS_NewNativeLocalFile failed(xuldir)" << std::endl;
        return -1;
    }

    nsCOMPtr<nsILocalFile> appdir;
    rv = NS_NewNativeLocalFile(nsCString(appDir.c_str()),
                               PR_FALSE, getter_AddRefs(appdir));
    if (NS_FAILED(rv)) {
        std::cout << "NS_NewNativeLocalFile failed(appdir)" << std::endl;
        return -1;
    }

    rv = XRE_InitEmbedding(xuldir, appdir, nsnull, nsnull, 0);
    if (NS_FAILED(rv)) {
        std::cout << "XRE_InitEmbedding failed" << std::endl;
        return -1;
    }

    XRE_TermEmbedding();
}


It compiled, at least, with

$ make
$ make target

$ cd target/
$ ./test
WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file /home/slanning/mozilla/src/cvs-xulrunner/mozilla/xpcom/base/nsTraceRefcntImpl.cpp, line 1085

(process:5405): GLib-GObject-CRITICAL **: gtype.c:2215: initialization assertion failed, use IA__g_type_init() prior to this function
[snip 7 more identical messages]

WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file /home/slanning/mozilla/src/cvs-xulrunner/mozilla/xpcom/base/nsTraceRefcntImpl.cpp, line 1085 WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file /home/slanning/mozilla/src/cvs-xulrunner/mozilla/xpcom/base/nsTraceRefcntImpl.cpp, line 971 [snip 2 more identical messages] WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file /home/slanning/mozilla/src/cvs-xulrunner/mozilla/xpcom/base/nsTraceRefcntImpl.cpp, line 1025
[snip many more warnings from lines 971 and 1025]
WARNING: NS_ENSURE_TRUE(compMgr) failed: file nsComponentManagerUtils.cpp,
line 90   [snip 2 more identical lines]
Type Manifest File: /home/slanning/mozilla/src/cvs-xulrunner/target/components/xpti.dat
*** Registering xpconnect components (all right -- a generic module!)
*** Registering nsUCvMathModule components (all right -- a generic module!)
*** Registering nsUConvModule components (all right -- a generic module!)
*** Registering nsI18nModule components (all right -- a generic module!)
*** Registering nsUniversalCharDetModule components (all right -- a generic module!)
*** Registering necko components (all right -- a generic module!)
*** Registering nsCookieModule components (all right -- a generic module!)
*** Registering nsPermissionsModule components (all right -- a generic module!)
*** Registering nsAuthModule components (all right -- a generic module!)
*** Registering nsJarModule components (all right -- a generic module!)
*** Registering nsPrefModule components (all right -- a generic module!)
*** Registering nsSecurityManagerModule components (all right -- a generic module!)
*** Registering nsRDFModule components (all right -- a generic module!)
*** Registering nsParserModule components (all right -- a generic module!)
*** Registering nsGfxPSModule components (all right -- a generic module!)
*** Registering nsGfxModule components (all right -- a generic module!)
*** Registering nsWidgetGtk2Module components (all right -- a generic module!)
*** Registering nsImageLib2Module components (all right -- a generic module!)
*** Registering nsPluginModule components (all right -- a generic module!)
*** Registering nsLayoutModule components (all right -- a generic module!)
*** Registering nsXMLExtrasModule components (all right -- a generic module!)
*** Registering nsWebServicesModule components (all right -- a generic module!)
*** Registering docshell_provider components (all right -- a generic module!)
*** Registering embedcomponents components (all right -- a generic module!)
*** Registering Browser_Embedding_Module components (all right -- a generic module!)
*** Registering nsEditorModule components (all right -- a generic module!)
*** Registering nsCJVMManagerModule components (all right -- a generic module!)
*** Registering nsAccessibilityModule components (all right -- a generic module!)
*** Registering appshell components (all right -- a generic module!)
*** Registering nsTransactionManagerModule components (all right -- a generic module!)
*** Registering nsComposerModule components (all right -- a generic module!)
*** Registering nsChromeModule components (all right -- a generic module!)
*** Registering nsFindComponent components (all right -- a generic module!)
*** Registering application components (all right -- a generic module!)
*** Registering nsWindowDataSourceModule components (all right -- a generic module!)
*** Registering nsXPIntlModule components (all right -- a generic module!)
*** Registering Apprunner components (all right -- a generic module!)
*** Registering CommandLineModule components (all right -- a generic module!)
*** Registering nsFileViewModule components (all right -- a generic module!)
*** Registering mozStorageModule components (all right -- a generic module!)
*** Registering tkAutoCompleteModule components (all right -- a generic module!)
*** Registering satchel components (all right -- a generic module!)
*** Registering PKI components (all right -- a generic module!)
*** Registering nsToolkitCompsModule components (all right -- a generic module!)
*** Registering RemoteServiceModule components (all right -- a generic module!)
*** Registering nsSoftwareUpdate components (all right -- a generic module!)
*** Registering JavaScript_Debugger components (all right -- a generic module!)
*** Registering BOOT components (all right -- a generic module!)
*** Registering NSS components (all right -- a generic module!)
*** Registering nsAutoConfigModule components (all right -- a generic module!)
nsNativeModuleLoader::LoadModule("/home/slanning/mozilla/src/cvs-xulrunner/target/components/libmozgnome.so") - load FAILED, rv: 80004005, error: /home/slanning/mozilla/src/cvs-xulrunner/target/components/libmozgnome.so: cannot open shared object file: No such file or directory [snip similar messages for: libtestdynamic.so, libMyService.so, libxpcomsample.so, libxpcomsample.so, libimgicon.so, libimgicon.so,
libwsproxytest.so, libwsproxytest.so, libnkgnomevfs.so, all these libraries
in target/components/ that were copied from dist/bin/. ]

###!!! ASSERTION: This is not supposed to fail!: 'Error', file /home/slanning/mozilla/src/cvs-xulrunner/mozilla/js/src/xpconnect/src/nsXPConnect.cpp, line 395 ###!!! ASSERTION: Failed to initialize nsScriptSecurityManager: 'NS_SUCCEEDED(rv)', file /home/slanning/mozilla/src/cvs-xulrunner/mozilla/caps/src/nsScriptSecurityManager.cpp, line 3118
[snip about 50 more of the last two lines]
WARNING: Cannot create startup observer : service,@mozilla.org/scriptsecuritymanager;1: file /home/slanning/mozilla/src/cvs-xulrunner/mozilla/embedding/components/appstartup/src/nsAppStartupNotifier.cpp, line 112
JS API usage error: 36 contexts left in runtime upon JS_DestroyRuntime.
JS engine warning: leaking GC root 'res->input' at 0x80a7190
[similar thing 35 more times]
JS engine warning: 36 GC roots remain after destroying the JSRuntime.
                   These roots may point to freed memory. Objects reachable
                   through them have not been finalized.
WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file /home/slanning/mozilla/src/cvs-xulrunner/mozilla/xpcom/base/nsTraceRefcntImpl.cpp, line 1025
[snip 5 or 6 similar lines]
nsStringStats
 => mAllocCount:           1156
 => mReallocCount:            4
 => mFreeCount:            1156
 => mShareCount:           1811
 => mAdoptCount:              7
 => mAdoptFreeCount:          7
WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file /home/slanning/mozilla/src/cvs-xulrunner/mozilla/xpcom/base/nsTraceRefcntImpl.cpp, line 1122
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding

Reply via email to