简体   繁体   English

如何在C中包含第三方库?

[英]How to include third party library in C?

I want to include "libxml" library in my code. 我想在代码中包含“ libxml”库。 But I have no idea, How to include this library in my own code. 但是我不知道如何在我自己的代码中包含这个库。 I am using Turbo C++ IDE. 我正在使用Turbo C ++ IDE。

Thanks 谢谢

Your library will have some header files. 您的库将有一些头文件。 Suppose that you decide you need header files called "libxml_a.h", "libxml_b.h", and "libxml_c.h" for a file that references these libraries. 假设您决定需要引用这些库的文件的头文件“ libxml_a.h”,“ libxml_b.h”和“ libxml_c.h”。 Then you add the following lines to your code, 然后,将以下行添加到代码中,

#include "libxml_a.h"
#include "libxml_b.h"
#include "libxml_c.h"

//depending how you feel about using namespace
using namespace libxml; // or whatever their namespace is called

... //your code goes here

Your library will also have some object files (.obj, .o, .so, .a), and you will want to place them into a location where your linker can find them. 您的库中还将包含一些目标文件(.obj,.o,.so,.a),您需要将它们放置在链接程序可以找到它们的位置。 and tell your linker where to find these additional dependency files. 并告诉您的链接器在哪里可以找到这些其他依赖文件。 So you need to edit your project file and add this library path to your linker, 因此,您需要编辑项目文件并将此库路径添加到链接器,

library_path = ...<whatever lib path was>... <path to libxml>

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

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