简体   繁体   English

我是否需要在共享库中显式包括一个公共头文件(在include路径文件夹中)?

[英]Do I need to explicitly include a common header file(in an include path folder) used in shared library?

I am using a shared library , say, shr.so . 我正在使用共享库,例如shr.so This has some header file, say, shr_struct.h with structures I need to use in my program , say, main_prog.c . 这有一些头文件,比方说, shr_struct.h与我需要在我的程序中使用的结构,说, main_prog.c

Do I need to keep a copy of shr_struct.h in my include path so that I can declare objects of structure types in shr_struct.h in main_prog.c ? 我需要保持一份shr_struct.h在我的包含路径,这样我可以在声明结构类型的对象shr_struct.hmain_prog.c

If your main_prog.c depends on shr_struct.h , the compiler will need to know where this last file is located. 如果您main_prog.c取决于shr_struct.h ,编译器将需要知道这最后文件的位置。

Now if the library is installed in the system "standard" library path, you may not have to explicitly add this path to the compiler command as it may be smart enough to search in the standard system path by itself. 现在,如果该库已安装在系统“标准”库路径中,则您不必将此路径显式添加到编译器命令中,因为它可能足够聪明,可以自行搜索标准系统路径。

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

相关问题 使用外部库时是否必须包含 header 文件? - Do i have to include a header file when using an external library? 我是否需要在具有“特殊类型”的 header 文件中包含导入? - Do I need to include imports in a header file with 'special types'? 如果另一个头文件已经包含系统头文件,是否需要在源文件中包含它? - Do I need to include system header file in the source if another header file already includes it? 如何在Mac的标头包含路径中添加Allegro(或任何库)? - How do I add Allegro (or any library) to the header include path on Mac? 我应该 #include 库 header 吗? - Should I #include a library header? 为什么我需要在同名的.c文件中包含.h头文件? - why do i need to include a .h header file in the .c file of the same name? 如何将目录添加到C头包含路径? - How do I add a directory to C header include path? 如果每个需要的库都包含在我的主库中,我是否需要在具有 function 实现的文件中#include 任何内容? - Do I need to #include anything in a file with function implementations if every needed library is included in my main? 你需要在makefile中包含头文件吗? - Do you need to include header files in a makefile? 如何告诉链接器在头文件中包含一个库 - How to tell linker to include a library in header file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM