对使用开源第三方库感到困惑
如何在项目中集成 C 或 C++ 开源第三方库?您是否将其附带的所有文件(即自述文件、makefile 等)复制到项目内某个单独的目录并使用其配置来构建它?或者您只从源包中获取所需的源文件和标头?或者您只安装预构建的二进制文件?
如果我正在为 Windows 和 Linux 制作一个非常小的非 GUI 项目,那更好呢?
How do you integrate C or C++ open-source third party libraries in your projects? Do you copy all the files it comes with (I.e. README, makefiles etc) to a separate directory somewhere inside the project and build it using its configs? 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般的方法是放入您依赖的库的
README
和INSTALL
,并且用户应该下载并安装共享库。然后在编译时链接该共享库。除非有充分的理由(例如 gnulib),否则切勿将源代码放入您自己的应用程序中。
您的应用程序应该与第三方软件包的安装无关 - 将其留给用户。当他们在您构建的软件包中使用
rpm
、deb
、ports
或portage
时,这会告诉您它依赖什么打开后,其他软件包将自动安装。The generic way is to put in your
README
andINSTALL
that you depend on a library and that the user should download and install the shared library. Then link against that shared library at compile time.Never put the source into your own application unless theres a good reason (like 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
, orportage
with the packages you build, which tell what it depends on, the other package will be automatically installed.