简体   繁体   English

C ++和对XML_Parser的未定义引用

[英]C++ and undefined reference to XML_Parser

i have the following problem, i need use expat.h library, i include the library normally: 我有以下问题,我需要使用expat.h库,我通常包含该库:

#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 . Eclipse Keppler返回对XML_ParserCreate的未定义引用 I check the library and is included. 我检查了图书馆并包含在内。 I work with ubuntu 13.04 and g++ compiler. 我使用ubuntu 13.04和g ++编译器。

any idea? 任何想法?

Probably you didn't link with the library. 可能您没有链接到库。 You should add this -lexpat to the compiler`s command line. 您应该将此-lexpat添加到编译器的命令行中。 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) . 一个更高级的(并且更易于使用,当您$(pkg-config --libs expat)将使用pkg-config ,例如$(pkg-config --libs expat)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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