Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Package vs Library

I've just started working with CMake and I noticed that they have both a find_package and a find_library. And this confuses me. Can somebody explain the difference between a package and a library in the world of programming? Or, in the world of CMake?

Appreciate it, guys!

like image 279
assignment_operator Avatar asked May 23 '14 14:05

assignment_operator


People also ask

What is the difference between package and library?

However, it is often assumed that while a package is a collection of modules, a library is a collection of packages. Oftentimes, developers create Python libraries to share reusable code with the community.

Is library and package same in Python?

Package is a collection of modules. It must contain an __init__.py file as a flag so that the python interpreter processes it as such. The __init__.py could be an empty file without causing issues. Library is a collection of packages.

What are the packages in library?

Packages are collections of R functions, data, and compiled code in a well-defined format, created to add specific functionality. There are 10,000+ user contributed packages and growing.

What is difference between library and modules?

Also, a library is a collection of related functionality, whereas a module only provides a single piece of functionality. Which means that, if you have a system with both modules and libraries, a library will typically contain multiple modules.


1 Answers

Imagine you want to use zlib in your project, you need to find the header file zlib.h, and the library libz.so (on Linux). You can use the low-level cmake commands find_path and find_library to find them, or you can use find_package(ZLIB). The later command will try to find out all what is necessary to use zlib. It can be extra macro definitions, or dependencies.

Update, more detail about find_package: when the CMake command find_package(SomeThing) is called, as in the documentation, there are two possible modes that cmake can run:

  • the module mode (that searches for a file FindSomeThing.cmake)
  • or the config mode (that searches for a file named SomeThingConfig.cmake)

For ZLIB, there is a module named FindZLIB, shipped with CMake itself (on my Linux machine that is the file /usr/share/cmake/Modules/FindZLIB.cmake). That module is a CMake script that uses the CMake API to search for ZLIB files in default locations, or ask the user for the location if it cannot be found automatically.

like image 177
lrineau Avatar answered Oct 06 '22 04:10

lrineau