简体   繁体   中英

C++ and undefined reference to XML_Parser

i have the following problem, i need use expat.h library, i include the library normally:

#include <expat.h>

But when i try to create a object

XML_Parser Parser = XML_ParserCreate(NULL);

Eclipse keppler return undefined reference to XML_ParserCreate . I check the library and is included. I work with ubuntu 13.04 and g++ compiler.

any idea?

Probably you didn't link with the library. You should add this -lexpat to the compiler`s command line. For example:

g++ main.cc -lexpat -o exe

A more advanced (and more easy to use, when you get up to speed) option would be to use pkg-config as eg $(pkg-config --libs expat) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM