Fedora 下 Firefox 未加载 XPCOM 组件

发布于 2024-10-15 04:49:52 字数 2547 浏览 1 评论 0原文

我正在尝试在LINUX操作系统下为Firefox 3.6.13构建简单的XPCOM组件。我使用 Xulrunner SDK 1.9.2.13 成功编译了该组件。我把它保存在组件目录下。但是当我启动我的 Firefox 时,Firefox 控制台显示错误

'加载 XPCOM 组件失败: /home/mypc/.mozilla/firefox/cxsm79p6.default/extensions/{1280606b-2510-4fe0-97ef-9b5a22eafe80}/components/MyComponent.so

通过参考此链接 https://developer.mozilla.org/en/Troubleshooting_XPCOM_components_registration,我按照标题“Linux 特定提示”下的说明进行操作。它表示在链接时使用特殊的链接时间选项-Wl,-z,defs。所以我添加了这些选项,但现在编译时显示错误为

make:警告:文件“Makefile”的修改时间为未来 0.25 秒

c++ -Os -Wall -o MyComponent.so -include xpcom-config.h -DXPCOM_GLUE_USE_NSPR -I /mnt/hgfs/C/Users/sunil/SDKS/LINUX/xulrunner-sdk/include -I./ -L /mnt/hgfs/C/Users/sunil/SDKS/LINUX/xulrunner-sdk/lib -lxpcomglue_s -lxpcom -lnspr4 -fno-rtti -fno-exceptions -shared -Wl,-z,defs MyComponent.cpp MyComponentModule.cpp /tmp/ccMGUTql.o:功能中 MyComponent::QueryInterface(nsID const&, void**)': MyComponent.cpp:(.text+0x9b): 未定义的引用NS_TableDrivenQI(void*, QITableEntry const*, nsID const&, void**)' /tmp/ccbkZLTz.o:功能中 NSGetModule': MyComponentModule.cpp:(.text+0x15): 未定义的引用 NS_NewGenericModule2(nsModuleInfo const*, nsIModule*)'collect2: ld 返回 1 退出状态 make: ** [构建]错误1

​​我的新 makefile 如下

CXX   = c++
CPPFLAGS +=     -fno-rtti              \
                -fno-exceptions        \
                -shared                 \
                -Wl,-z,defs

# Change this to point at your Gecko SDK directory. 
GECKO_SDK_PATH =/mnt/hgfs/C/Users/sunil/SDKS/LINUX/xulrunner-sdk

# GCC only define which allows us to not have to #include mozilla-config 
# in every .cpp file.  If your not using GCC remove this line and add 
# #include "mozilla-config.h" to each of your .cpp files. 
GECKO_CONFIG_INCLUDE = -include xpcom-config.h

GECKO_DEFINES  = -DXPCOM_GLUE_USE_NSPR

GECKO_INCLUDES = -I $(GECKO_SDK_PATH)/include

GECKO_LDFLAGS =  -L $(GECKO_SDK_PATH)/lib -lxpcomglue_s -lxpcom \
                -lnspr4

FILES = MyComponent.cpp MyComponentModule.cpp

TARGET = MyComponent.so

build: 
        $(CXX) -Os -Wall  -o $(TARGET) $(GECKO_CONFIG_INCLUDE) $(GECKO_DEFINES) $(GECKO_INCLUDES) -I./ $(GECKO_LDFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(FILES)
        chmod +x $(TARGET)
        strip $(TARGET)

clean: 
        rm $(TARGET)

有人可以帮我解决这个问题吗?

I am trying to build simple XPCOM component for Firefox 3.6.13 under LINUX operating system. I successfully compiled the component using Xulrunner SDK 1.9.2.13. I kept it under components directory. But when I start my firefox firefox console shows error

'Failed to load XPCOM component:
/home/mypc/.mozilla/firefox/cxsm79p6.default/extensions/{1280606b-2510-4fe0-97ef-9b5a22eafe80}/components/MyComponent.so

By referring to this link https://developer.mozilla.org/en/Troubleshooting_XPCOM_components_registration, I followed instructions under title 'Linux-specific hints'. It says to use special linking time option -Wl,-z,defs while linking. So I added these options but now while compiling its showing error as

make: Warning: File `Makefile' has modification time 0.25 s in the future

c++ -Os -Wall -o MyComponent.so
-include xpcom-config.h -DXPCOM_GLUE_USE_NSPR -I /mnt/hgfs/C/Users/sunil/SDKS/LINUX/xulrunner-sdk/include
-I./ -L /mnt/hgfs/C/Users/sunil/SDKS/LINUX/xulrunner-sdk/lib
-lxpcomglue_s -lxpcom -lnspr4 -fno-rtti -fno-exceptions -shared -Wl,-z,defs MyComponent.cpp MyComponentModule.cpp
/tmp/ccMGUTql.o: In function
MyComponent::QueryInterface(nsID
const&, void**)':
MyComponent.cpp:(.text+0x9b):
undefined reference to
NS_TableDrivenQI(void*, QITableEntry
const*, nsID const&, void**)'
/tmp/ccbkZLTz.o: In function
NSGetModule':
MyComponentModule.cpp:(.text+0x15):
undefined reference to
NS_NewGenericModule2(nsModuleInfo
const*, nsIModule*)' collect2: ld
returned 1 exit status make: *
*
[build] Error 1

My New makefile is as follows

CXX   = c++
CPPFLAGS +=     -fno-rtti              \
                -fno-exceptions        \
                -shared                 \
                -Wl,-z,defs

# Change this to point at your Gecko SDK directory. 
GECKO_SDK_PATH =/mnt/hgfs/C/Users/sunil/SDKS/LINUX/xulrunner-sdk

# GCC only define which allows us to not have to #include mozilla-config 
# in every .cpp file.  If your not using GCC remove this line and add 
# #include "mozilla-config.h" to each of your .cpp files. 
GECKO_CONFIG_INCLUDE = -include xpcom-config.h

GECKO_DEFINES  = -DXPCOM_GLUE_USE_NSPR

GECKO_INCLUDES = -I $(GECKO_SDK_PATH)/include

GECKO_LDFLAGS =  -L $(GECKO_SDK_PATH)/lib -lxpcomglue_s -lxpcom \
                -lnspr4

FILES = MyComponent.cpp MyComponentModule.cpp

TARGET = MyComponent.so

build: 
        $(CXX) -Os -Wall  -o $(TARGET) $(GECKO_CONFIG_INCLUDE) $(GECKO_DEFINES) $(GECKO_INCLUDES) -I./ $(GECKO_LDFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(FILES)
        chmod +x $(TARGET)
        strip $(TARGET)

clean: 
        rm $(TARGET)

Can somebody help me get around this ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

请别遗忘我 2024-10-22 04:49:52

我认为如果您的库未正确指定,您会收到此错误。其中一行可能会修复它:

GECKO_LDFLAGS = -L$(GECKO_SDK_PATH)/lib -L$(GECKO_SDK_PATH)/bin -Wl,-rpath-link,$(GECKO_SDK_PATH)/bin -lxpcomglue_s -lxpcom -lnspr4

$(CXX) -Os -Wall  -o $(TARGET) $(GECKO_CONFIG_INCLUDE) $(GECKO_DEFINES) $(GECKO_INCLUDES) -I./ $(CPPFLAGS) $(CXXFLAGS) $(FILES) $(GECKO_LDFLAGS)

I think you get this error if your libraries aren't specified correctly. One of these lines might fix it:

GECKO_LDFLAGS = -L$(GECKO_SDK_PATH)/lib -L$(GECKO_SDK_PATH)/bin -Wl,-rpath-link,$(GECKO_SDK_PATH)/bin -lxpcomglue_s -lxpcom -lnspr4

or

$(CXX) -Os -Wall  -o $(TARGET) $(GECKO_CONFIG_INCLUDE) $(GECKO_DEFINES) $(GECKO_INCLUDES) -I./ $(CPPFLAGS) $(CXXFLAGS) $(FILES) $(GECKO_LDFLAGS)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文