本文介绍了什么是组织我的C项目code和其外部库的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始一个新的C项目,这在很大程度上是基于OSS。这也将是在SourceForge上,我想借此机会,学习建立的最佳实践组织这类code的。我使用libcurl的喜欢和libz进行图书馆,我会用MinGW和MSYS编译。

I'm starting a new C project, which is largely OSS-based. It'll also be on SourceForge, and I'd like to take this opportunity to learn established best practices for organizing this kind of code. I'm using libraries like libcurl and libz, and I'll compile it using MinGW and MSYS.

我会复制分配我用我所有谟库的源,所以人们下载源不会去啄,并寻找相关性。我应该叫我的库存储在目录中?到目前为止,我犹豫之间:

I'll be distributing copies the source of all libraries I'm using with my projet, so people downloading the source won't have to go peck and hunt for dependencies. What should I call the directory I store the libraries in? So far, I hesitate between:


  • lib中,因为他们是库。然而,'库'在UNIX世界的一个不同的内涵。

  • SRC,因为它们的源文件。

  • 的3rdParty,因为我没有写。

和我应该在哪里编译这些库?我应该简单地配置并安装到系统根目录,或者我应该建立一个目录,所有的图书馆应编译和链接从那里?显然,这将有后果对我的Makefile文件。

And where should I compile these libraries to? Should I simply configure and install them to the system root, or should I set up a directory where all libraries should compile to, and link from there? Obviously, this will have ramifications for my Makefile.

我应该如何去吗?有没有确定,我应该遵循惯例?他们在什么地方写下来?

How should I go about this? Are there established conventions that I should follow? Are they written down somewhere?

推荐答案

首先,外部库,我会用厂商,但是这只是一个preference。

First, for external libraries I would use vendor, but that's just a preference.

第二,我不认为它是安装一个好主意的其他的库在系统根,没有用户的知识。最重要的,因为这将与这些库以后安装的版本发生冲突。所以我觉得对于这些库的最佳位置是在同一目录下的应用程序。

Second, I don't think it is a good idea to install other libraries in a system root, without the users knowledge. Most importantly because this will conflict with later installed versions of those libraries. So I think the best place for these libraries would be in the same directory as your application.

您也可以静态编译这些库到程序中。

You could also statically compile these libraries into your program.

这篇关于什么是组织我的C项目code和其外部库的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 04:16