conanconan-2

Difference between conan create and conan install


I have seen that the two commands can sometimes be used interchangeably. Can anyone point to the actual difference, and when you'd use conan install vs. when you'd use conan create?


Solution

  • conan install <path> install the dependencies listed in the conanfile.txt or conanfile.py, and uses the generators/generate() to write files that build systems can use, like CMakeToolchain generator will create a conan_toolchain.cmake file.

    This conan install is then a "pure consumer" command, to install the dependencies for a given project. But the current project is not creating a package itself, once conan install has been called, it is yet another regular C/C++ project. The conanfile.txt is good for this, and if using a conanfile.py, it doesn't need any of the build(), package() or package_info() method.

    The conan install is what is used in the "consuming packages" tutorial.

    On the other hand, the conan create requires a conanfile.py with the build(), package() and package_info() methods, and it will create a package in the Conan cache from the current project. This package can be later uploaded to a server too, and it can also be used from other projects in the current machine, as it is in the cache and available to be used as a package. The conan create is a "creator command".

    The conan create is what is explained in the "creating packages" tutorial.