Hi,
I'm working on my first XPCOM component. Unfortunately, I can't register it successfully.
Building is ok. Here's the makefile
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)
I created a new extension folder under my development firefox profile's extension directory. The IComponent.xpt and Component.so files are placed there under the component directory.
I then removed the compreg.dat and xpti.dat from my development firefox profile. I restarted it, which should automatically register the components. But the XPCOM viewer didn't show my component.
I ran this command to check for errors
./run-mozilla.sh `which ldd` -r /path/to/component/Component.so
It showed me several undefined symbols
...
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)
I've been using nsAString and COMPtr in my code.
Are there anything wrong with my steps? Can anyone explain why are there undefined symbols? What do undefined symbols mean? How do you get them recognised? Thanks!
Zan