简体   繁体   English

对使用开源第三方库感到困惑

[英]Confused in using opensource 3rd party libraries

How do you integrate C or C++ open-source third party libraries in your projects? 您如何在项目中集成C或C ++开源第三方库? Do you copy all the files it comes with (Ie README, makefiles etc) to a separate directory somewhere inside the project and build it using its configs? 您是否将其随附的所有文件(即README,makefiles等)复制到项目内部某个单独的目录,并使用其配置进行构建? Or do you only get needed source files and headers from a source package? 还是仅从源包中获取所需的源文件和头? Or do you just install pre-build binaries? 还是只安装预构建二进制文件?

What's better if I'm making a very little non-GUI project for both Windows and Linux? 如果我同时为Windows和Linux编写一个非常小的非GUI项目,那会更好吗?

The generic way is to put in your README and INSTALL that you depend on a library and that the user should download and install the shared library. 通用方法是放入您依赖库的READMEINSTALL ,并且用户应下载并安装共享库。 Then link against that shared library at compile time. 然后在编译时链接到该共享库。

Never put the source into your own application unless theres a good reason (like gnulib). 除非有充分的理由(例如gnulib),否则切勿将源代码放入您自己的应用程序中。

Your application should have nothing to do with the installation of the third party package - leave that to the user. 您的应用程序应与第三方软件包的安装无关-留给用户。 When they use rpm , deb , ports , or portage with the packages you build, which tell what it depends on, the other package will be automatically installed. 当他们在您构建的软件包中使用rpmdebportsportage时,它会告诉您它依赖什么,另一个软件包将被自动安装。

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

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