M
micropentium
Hi,
First of all, I know my compilation should fail anyway. Let's focus on
this link error.
I was writing some dummy code to test xulrunner sdk (probably I picked
the wrong way, but it's not important here) and then a weird error pop
up when I tried to link my code with its static library:
libembed_base_s.a
The compile looks like:
g++ -o test -g -Wall -Wno-non-virtual-dtor libembed_base_s.a test.o
The error I got was: ./test.cpp:40: undefined reference to
`NS_InitEmbedding'
So, I thought I must link with the wrong lib. Therefore, I did nm
libembed_base_s.a. Here is what I got:
nsEmbedAPI.o:
0000000000000000 r .LC0
000000000000002d r .LC1
0000000000000039 r .LC2
000000000000005a r .LC3
000000000000005e T NS_InitEmbedding
U NS_InitXPCOM3
U NS_ShutdownXPCOM
0000000000000000 T NS_TermEmbedding
U _GLOBAL_OFFSET_TABLE_
0000000000000000 V _ZN11nsIObserver11COMTypeInfoIiE4kIIDE
0000000000000000 V _ZN19nsIComponentManager11COMTypeInfoIiE4kIIDE
0000000000000000 V _ZN22nsIStringBundleService11COMTypeInfoIiE4kIIDE
0000000000000000 b sInitCounter
0000000000000010 b sRegistryInitializedFlag
0000000000000008 b sServiceManager
It seems the symbol is defined and exported in the object file. Yes, I
know there are undefined functions in
NS_InitEmbedding, such as NS_InitXPCOM3. But according to the error,
the linker actually didn't find the NS_InitEmbedding at all! So,
anyone could kindly explain to me what's going on?
In order to make this topic more interesting, I did: objdump -t
libembed_base_s.a
Then you could see:
000000000000005e g F .text 000000000000014a .hidden
NS_InitEmbedding
There is a hidden flag for this symbol, I know it's because the
declaration of __attribute__((visibility("hidden"))) on this function.
But, imho, I believe it only affects DSO, not static library archive.
So, I still do not know what kind of trick it plays to prevent linker
to detect this symbol. I have been on this for 1 days, and no clue so
far.
Your help will be highly appreciated!
Many Thanks!
First of all, I know my compilation should fail anyway. Let's focus on
this link error.
I was writing some dummy code to test xulrunner sdk (probably I picked
the wrong way, but it's not important here) and then a weird error pop
up when I tried to link my code with its static library:
libembed_base_s.a
The compile looks like:
g++ -o test -g -Wall -Wno-non-virtual-dtor libembed_base_s.a test.o
The error I got was: ./test.cpp:40: undefined reference to
`NS_InitEmbedding'
So, I thought I must link with the wrong lib. Therefore, I did nm
libembed_base_s.a. Here is what I got:
nsEmbedAPI.o:
0000000000000000 r .LC0
000000000000002d r .LC1
0000000000000039 r .LC2
000000000000005a r .LC3
000000000000005e T NS_InitEmbedding
U NS_InitXPCOM3
U NS_ShutdownXPCOM
0000000000000000 T NS_TermEmbedding
U _GLOBAL_OFFSET_TABLE_
0000000000000000 V _ZN11nsIObserver11COMTypeInfoIiE4kIIDE
0000000000000000 V _ZN19nsIComponentManager11COMTypeInfoIiE4kIIDE
0000000000000000 V _ZN22nsIStringBundleService11COMTypeInfoIiE4kIIDE
0000000000000000 b sInitCounter
0000000000000010 b sRegistryInitializedFlag
0000000000000008 b sServiceManager
It seems the symbol is defined and exported in the object file. Yes, I
know there are undefined functions in
NS_InitEmbedding, such as NS_InitXPCOM3. But according to the error,
the linker actually didn't find the NS_InitEmbedding at all! So,
anyone could kindly explain to me what's going on?
In order to make this topic more interesting, I did: objdump -t
libembed_base_s.a
Then you could see:
000000000000005e g F .text 000000000000014a .hidden
NS_InitEmbedding
There is a hidden flag for this symbol, I know it's because the
declaration of __attribute__((visibility("hidden"))) on this function.
But, imho, I believe it only affects DSO, not static library archive.
So, I still do not know what kind of trick it plays to prevent linker
to detect this symbol. I have been on this for 1 days, and no clue so
far.
Your help will be highly appreciated!
Many Thanks!