I can’t seem to link the following program:
#include <stdio.h>
extern “C” {
#include <xmlnode.h>
#include <xmltree.h>
}
int main( void ) {
xml_treelist_t *tree = XML_TreeListInit();
}
I use the following command to compile & link:
qcc -static -lxml -o xml1 xml1.cc
This is the error that results:
xml1.o: In function main': xml1.o(.text+0x7): undefined reference to
XML_TreeListInit’
cc: /usr/ntox86/bin/ld error 1
After compiling to produce just an object file, an objdump -x
produces the following:
xml1.o: file format elf32-i386
xml1.o
architecture: i386, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x00000000
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000016 00000000 00000000 00000034 22
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
1 .data 00000000 00000000 00000000 0000004c 22
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 0000004c 22
ALLOC
3 .note 00000014 00000000 00000000 0000004c 20
CONTENTS, READONLY
4 .eh_frame 0000002c 00000000 00000000 00000060 22
CONTENTS, ALLOC, LOAD, RELOC, DATA
5 .comment 00000026 00000000 00000000 0000008c 20
CONTENTS, READONLY
SYMBOL TABLE:
00000000 l df ABS 00000000 xml1.cc
00000000 l d .text 00000000
00000000 l d .data 00000000
00000000 l d .bss 00000000
00000000 l .text 00000000 gcc2_compiled.
00000000 l d .eh_frame 00000000
00000000 l .eh_frame 00000000 FRAME_BEGIN
00000000 l d .note 00000000
00000000 l d .comment 00000000
00000000 g F .text 00000016 main
00000000 UND 00000000 XML_TreeListInit
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000007 R_386_PC32 XML_TreeListInit
RELOCATION RECORDS FOR [.eh_frame]:
OFFSET TYPE VALUE
0000001c R_386_32 .text
The function XML_TreeListInit is listed as undefined as expected.
An abbreviated objdump -x of /usr/lib/libxml.a reports:
0000019c g F .text 00000014 XML_TreeListInit
Despite what appears to be the target function I get the same undefined
reference whether I specify “-lxml” or not.
Can anyone tell me what’s missing?
TIA
Harry Qualls,
Tree-D, Inc.