简体   繁体   English

将包含与 C++ 共享库一起使用

[英]Using includes with c++ shared libraries

I have a few functions that need to use math.h and time.h that I'd like to stick in a c++ shared library.我有一些需要使用 math.h 和 time.h 的函数,我想将它们放在 c++ 共享库中。

I'm having a hard time finding examples through google.我很难通过谷歌找到例子。

Where do I put the #include , the main file?我在哪里放置 #include ,主文件? The library cpp?图书馆cpp? or should it be in the make file?还是应该在make文件中? Is there any special syntax involved?是否涉及任何特殊语法?

If anything in math.h or time.h shows up in your library routines' interface, then the includes must be in your library's .h since they must be visible to the code that calls your library routines.如果math.htime.h中的任何内容出现在您的库例程的界面中,则包含必须在您的库的.h因为它们必须对调用您的库例程的代码可见。 Othewise it's quite acceptable (to the compiler, at least,) to hide them away inside the library's .cpp file.否则,将它们隐藏在库的.cpp文件中是完全可以接受的(至少对编译器而言)。

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

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