Monday, 15 July 2013

c - Cannot Work with mxmlGetText and mxmlGetElemet in mxml -



c - Cannot Work with mxmlGetText and mxmlGetElemet in mxml -

#include <mxml.h> #include <stdio.h> void main() { file *fp; mxml_node_t *tree; mxml_node_t *node = null; fp = fopen("1.xml", "r"); tree = mxmlloadfile(null, fp, mxml_opaque_callback); node = tree; fprintf(stderr, "element::%s\n", mxmlgetelement(node)); fprintf(stderr, "value::%s\n", mxmlgettext(node, 0)); }

above code snippet ... error is

xmlparsing.c: in function ‘main’: xmlparsing.c:20:2: warning: format ‘%s’ expects argument of type ‘char *’, argument 3 has type ‘int’ [-wformat] xmlparsing.c:21:2: warning: format ‘%s’ expects argument of type ‘char *’, argument 3 has type ‘int’ [-wformat] /tmp/ccaysmob.o: in function `main': xmlparsing.c:(.text+0x58): undefined reference `mxmlgetelement' xmlparsing.c:(.text+0x8c): undefined reference `mxmlgettext' collect2: ld returned 1 exit status

already included mxml.h why undefined reference? searched functions on internet, , links show me it's in mxml.h header file.

your problem linker, see lastly message:

collect2: ld returned 1 exit status

you need inform gcc (which phone call compiler , linker include path , library path. include path mxml.h found, done with:

-i<path/to/include/mxml.h>

the library path given with:

-l<path/to/shared/libmxml.a>

so in total should have:

gcc yourfile.c -i <path/to/include/mxml.h> -l <path/to/shared/libmxml.a>

you can include other paths needed.

c gcc mxml

No comments:

Post a Comment