Вопрос

I wrote a program which uses Cryptopp library. 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.hwhich in turn is based on other header files in Cryptopp, a long chain. Do I include all header files from the Cryptopp library?

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?

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 с атрибуция
Не связан с StackOverflow
scroll top