简体   繁体   English

XPCOM组件DLL加载到Firefox中,但随后无法注册其类

[英]XPCOM component DLL loads into Firefox, but then fails to register its class

I have an XPCOM component whose source when compiled, works fine on Linux, but does not work on Windows. 我有一个XPCOM组件,其源代码在编译时可以在Linux上正常运行,但在Windows上则无法运行。 The DLL is clearly being loaded as expected by Firefox as revealed by the dependency walker program, but it appears never to be executed by it. DLL显然已经按照Firefox的预期进行了加载,如依赖项遍历程序所揭示的那样,但它似乎从未被执行。

This is the command line I am using to compile it all: 这是我用来编译所有内容的命令行:

[4/5] cxx: components\nsSoundSubsystem.cpp -> build\components\nsSoundSubsystem.cpp.2.o
15:44:31 runner ['C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\BIN\\CL.exe', '/nologo', '/MT', '/IE:\\src\\chunder\\clients\\xpcomextension\\build', '/IE:\\src\\chunder\\clients\\xpcomextension', '/IE:\\src\\chunder\\clients\\xpcomextension\\build\\components', '/IE:\\src\\chunder\\clients\\xpcomextension\\components', '/IC:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\INCLUDE', '/IC:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\include', '/Ic:\\xulrunner-sdk\\include', '/DHAVE_XPCOM_CONFIG_H=1', '/DMOZ_NO_MOZALLOC', '/DWIN32', '/D_WINDOWS', '/D_USRDLL', '/DXP_WIN', '/DXP_WIN32', '/DXPCOM_GLUE_USE_NSPR', '..\\components\\nsSoundSubsystemModule.cpp', '/FC', '/c', '/Focomponents\\nsSoundSubsystemModule.cpp.2.o']
15:44:31 runner ['C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\BIN\\CL.exe', '/nologo', '/MT', '/IE:\\src\\chunder\\clients\\xpcomextension\\build', '/IE:\\src\\chunder\\clients\\xpcomextension', '/IE:\\src\\chunder\\clients\\xpcomextension\\build\\components', '/IE:\\src\\chunder\\clients\\xpcomextension\\components', '/IC:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\INCLUDE', '/IC:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\include', '/Ic:\\xulrunner-sdk\\include', '/DHAVE_XPCOM_CONFIG_H=1', '/DMOZ_NO_MOZALLOC', '/DWIN32', '/D_WINDOWS', '/D_USRDLL', '/DXP_WIN', '/DXP_WIN32', '/DXPCOM_GLUE_USE_NSPR', '..\\components\\nsSoundSubsystem.cpp', '/FC', '/c', '/Focomponents\\nsSoundSubsystem.cpp.2.o']
nsSoundSubsystem.cpp
nsSoundSubsystemModule.cpp
[5/5] cxxshlib: build\components\nsSoundSubsystemModule.cpp.2.o build\components\nsSoundSubsystem.cpp.2.o -> build\components\chunder_x86.dll build\components\chunder_x86.dll.manifest build\components\chunder_x86.lib
15:44:32 runner ['C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\BIN\\LINK.exe', 'components\\nsSoundSubsystemModule.cpp.2.o', 'components\\nsSoundSubsystem.cpp.2.o', '/OUT:E:\\src\\chunder\\clients\\xpcomextension\\build\\components\\chunder_x86.dll', '/LIBPATH:C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\LIB', '/LIBPATH:C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\lib', '/LIBPATH:c:\\xulrunner-sdk\\lib', 'xpcom.lib', 'xpcomglue_s_nomozalloc.lib', 'nspr4.lib', '/NOLOGO', '/MANIFEST', '/DLL', '/machine:I386', '/IMPLIB:components\\chunder_x86.lib']
   Creating library components\chunder_x86.lib and object components\chunder_x86.exp
15:44:33 runner ['C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\bin\\MT.exe', '/NOLOGO', '-manifest', 'E:\\src\\chunder\\clients\\xpcomextension\\build\\components\\chunder_x86.dll.manifest', '-outputresource:E:\\src\\chunder\\clients\\xpcomextension\\build\\components\\chunder_x86.dll;2']

I am at my wits' end, three days in this chase. 在这个追赶过程中,我呆了三天。

What am I doing wrong? 我究竟做错了什么? Alternatively, what can I do to help me debug the issue? 另外,我该怎么做才能解决问题?

Additional info: I am using Firefox 4 to run the module, and the XULrunner 2.0 SDK to compile the module. 附加信息:我使用Firefox 4运行该模块,并使用XULrunner 2.0 SDK编译该模块。 The interface from the XPT file registers itself just fine. XPT文件中的接口注册本身就很好。

Looking at nsNativeModuleLoader::LoadModule , dependencies are not the problem here - failing dependencies would result in the library not loading in the first place, there wouldn't be anything to unload. 查看nsNativeModuleLoader::LoadModule ,依赖关系不是这里的问题-依赖关系失败将首先导致库未加载,没有任何要卸载的内容。 There are two conditions under which the library will be unloaded: symbol NSModule is not defined or module version doesn't match. 在两种情况下将卸载该库:未定义符号NSModule或模块版本不匹配。 From your description, the former is the problem, it should really be NSModule and not _NSModule . 从您的描述来看,前者是问题所在,它实际上应该是NSModule而不是_NSModule So I guess that you are using something other than NSMODULE_DEFN() macro. 所以我想您使用的不是NSMODULE_DEFN()宏。 See http://mxr.mozilla.org/mozilla-central/source/xpcom/sample/nsSampleModule.cpp for an example of a correct module definition. 有关正确的模块定义的示例,请参见http://mxr.mozilla.org/mozilla-central/source/xpcom/sample/nsSampleModule.cpp Should my guess be incorrect please show us your module definition code. 如果我的猜测不正确,请向我们显示您的模块定义代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM