简体   繁体   English

使用某些库分发程序(源文件)

[英]Distributing a program(source files) using some library

I wrote a program which uses Cryptopp library. 我写了一个使用Cryptopp库的程序。 I have created the static library and will include it my distribution, but the program also requires a lot of header files. 我已经创建了静态库,并将其包含在我的发行版中,但是该程序还需要很多头文件。 My question is do I need to include all those header files with my distribution? 我的问题是我需要在发行版中包含所有这些头文件吗?

For examples, I wrote a code which uses des.h , modes.h and filters.h which in turn is based on other header files in Cryptopp, a long chain. 对于实施例,我写其使用代码des.hmodes.hfilters.h而这又是基于在Cryptopp,长链其他的头文件。 Do I include all header files from the Cryptopp library? 我是否包括Cryptopp库中的所有头文件?

Making it more general, if I write some code which use other libraries(like Cryptopp or boost) what all do I need to include in distro? 更一般地说,如果我编写一些使用其他库的代码(例如Cryptopp或boost),那么我需要在发行版中包含什么?

Update : I want to distribute the source, not just the binaries. 更新 :我想分发源代码,而不仅仅是二进制文件。 So that the user can compile my program from scratch if we wants to. 这样,如果我们愿意,用户可以从头开始编译我的程序。 I'm including the static library, but confused about header files. 我包括静态库,但对头文件感到困惑。 Do I need to include them all? 我需要全部包括在内吗?

No, you only distribute binary files. 不,您只分发二进制文件。 You don't need headers to run a program. 您不需要标题即可运行程序。

If, however, you're distributing a library (not a program), you need to supply headers. 但是,如果要分发库(而不是程序),则需要提供标头。 Your headers, not third-party headers. 您的标头,而不是第三方标头。

You can exclude the third-party headers by a number of techniques, if they are part of the implementation only. 如果第三方标头仅是实现的一部分,则可以通过多种方法来排除它们。 If not, you'll need to supply them also. 如果不是,则还需要提供它们。 Assuming you don't need that, and you only use them internally, you can use forward declarations: 假设您不需要,并且只在内部使用它们,则可以使用前向声明:

//MyClass.h
class ExternalClass;
class MyClass
{
   ExternalClass* p;
} ;

This way, you only need to include the third-party header in your implementation file, which you don't distribute anyway. 这样,您只需要在实现文件中包括第三方标头,无论如何您都不会分发。

Generally, you want to do one of two things: either don't distribute the library at all or else distribute the whole library, exactly as-is. 通常,您想做两件事之一:要么根本不分发库,要么完全按原样分发整个库。

If you're only distributing a binary executable, the first makes sense. 如果您仅分发二进制可执行文件,则第一个有意义。 If you're distributing source code, you can do either. 如果要分发源代码,则可以执行任何一种操作。 Trying to do halfway between the two and just distribute parts of the library upon which your code depends is a recipe for problems. 尝试在两者之间做一半,只分发代码所依赖的库的一部分,这是解决问题的方法。

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

相关问题 是否有一些类似于boost program_options的c ++库/源代码,但是提供了*键盘快捷键自动生成帮助*? - is there some c++ library / source similar to boost program_options but for *keyboard shortcut auto-gen help* ? 分发Boost Library? - Distributing with Boost Library? 从使用另一个共享库的源文件中构建和使用共享库。 (RInside) - Building and using a shared library from source files that use another shared library. (RInside) 如何使用 CMake 为静态库(不使用源文件)创建共享库包装器? - How to create a shared library wrapper for a static library (without using source files) with CMake? 用我的程序分配共享对象 - Distributing shared objects with my program 具有依赖项的C ++分发程序 - C++ distributing program with dependencies 分发 Cython 生成的 cpp 文件 - Distributing cpp files generated by Cython MKV文件的开源WinRT库 - Open Source WinRT Library For MKV Files 使用没有标准库的预处理器连接 C++ 源文件包括 - Concatenating C++ source files using the preprocessor without standard library includes 使用库将库包含与程序分离 - Separating Library Includes From Program Using Library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM