我正在處理我的第一個XPCOM組件。不幸的是,我無法成功註冊。問題註冊XPCOM組件
建築是好的。這裏的
CXX = g++
CPPFLAGS += -fno-rtti \
-fexceptions \
-shared \
-fshort-wchar
# Change this to point at your Gecko SDK directory.
GECKO_SDK_PATH = /path/to/gecko/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 ${GECKO_SDK_PATH}/include/xpcom/xpcom-config.h
GECKO_DEFINES = -DXPCOM_GLUE -DXPCOM_GLUE_USE_NSPR
GECKO_INCLUDES = -I ${GECKO_SDK_PATH}/sdk/include \
-I ${GECKO_SDK_PATH}/include/necko \
-I ${GECKO_SDK_PATH}/include/nss \
-I ${GECKO_SDK_PATH}/include/nspr
GECKO_LDFLAGS = -L${GECKO_SDK_PATH}/lib -L${GECKO_SDK_PATH}/bin -Wl,-rpath-link,${GECKO_SDK_PATH}/bin -lxpcomglue_s -lxpcom -lnspr4
FILES = Component.cpp ComponentModule.cpp
TARGET = Component.so
build:
$(CXX) -Wall -Os -o $(TARGET) $(GECKO_CONFIG_INCLUDE) $(GECKO_DEFINES) $(GECKO_INCLUDES) $(GECKO_LDFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(FILES)
chmod +x $(TARGET)
strip $(TARGET)
clean:
rm $(TARGET)
我我開發的Firefox配置文件的擴展名目錄下創建一個新的擴展文件夾生成文件。 IComponent.xpt和Component.so文件放置在組件目錄下。
然後我從我的開發firefox配置文件中刪除了compreg.dat和xpti.dat。我重新啓動它,它應該自動註冊組件。但是XPCOM查看器沒有顯示我的組件。
我跑這個命令來檢查錯誤
./run-mozilla.sh `which ldd` -r /path/to/component/Component.so
這表明我的幾個不確定的符號
...
undefined symbol: _ZNK9nsAString12BeginReadingEv (/path/to/component/Component.so)
undefined symbol: _ZNK10nsACString12BeginReadingEv (/path/to/component/Component.so)
undefined symbol: _ZN9nsAString17DefaultComparatorEPKtS1_j (/path/to/component/Component.so)
undefined symbol: _ZNK9nsAString6EqualsEPKtPFiS1_S1_jE (/path/to/component/Component.so)
undefined symbol: _ZN9nsAString13AssignLiteralEPKc (/path/to/component/Component.so)
undefined symbol: _ZN13nsCOMPtr_base16begin_assignmentEv (/path/to/component/Component.so)
undefined symbol: _ZN13nsCOMPtr_baseD2Ev (/path/to/component/Component.so)
undefined symbol: _Z16NS_TableDrivenQIPvPK12QITableEntryRK4nsIDPS_ (/path/to/component/Component.so)
undefined symbol: _Z20NS_NewGenericModule2PK12nsModuleInfoPP9nsIModule (/path/to/component/Component.so)
我一直在使用nsAString和COMPtr在我的代碼。
我的步驟有什麼問題嗎?任何人都可以解釋爲什麼有未定義的符號?未定義的符號是什麼意思?你如何得到他們的認可?
其實我切換到的JavaScript編寫XPCOM。這很容易!我將很快寫一篇關於編寫javascript XPCOM的博客文章 – liangzan 2009-03-28 01:23:23