我需要显式地包括在共享库中使用的公共头文件(在包含路径文件夹)吗? [英] Do I need to explicitly include a common header file(in an include path folder) used in shared library?

查看:336
本文介绍了我需要显式地包括在共享库中使用的公共头文件(在包含路径文件夹)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是共享库,例如 shr.so 。这有一些头文件,例如, shr_struct.h 结构我需要在我的程序中使用,例如, main_prog.c



我需要在我的include路径中保留 shr_struct.h 的副本,在 main_prog.c

中的 shr_struct.h 中声明结构类型的对象

main_prog.c 取决于 shr_struct.h ,编译器将需要知道这最后一个文件所在的位置。



现在如果库安装在系统的标准库路径中,显式地将此路径添加到编译器命令中,因为它可能足够聪明以自行在标准系统路径中搜索。


I am using a shared library , say, shr.so. This has some header file, say, shr_struct.h with structures I need to use in my program , say, 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?

解决方案

If your main_prog.c depends on shr_struct.h, the compiler will need to know where this last file is located.

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.

这篇关于我需要显式地包括在共享库中使用的公共头文件(在包含路径文件夹)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆